From patchwork Mon Oct 4 10:23:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14040 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 979B7C3243 for ; Mon, 4 Oct 2021 10:23:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19038691B6; Mon, 4 Oct 2021 12:23:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GcjNqGV+"; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B3946023F for ; Mon, 4 Oct 2021 12:23:21 +0200 (CEST) Received: by mail-pj1-x1033.google.com with SMTP id rj12-20020a17090b3e8c00b0019f88e44d85so5259614pjb.4 for ; Mon, 04 Oct 2021 03:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LHeASP5+vsxBDXMOMf/ygQLASUU6jccN+T5LlmzvuUM=; b=GcjNqGV+e0MbQA4NefXR0QcoTeJoGJDspwkcg3q6t+ZKYPbBPLBXSxpBemQtRzOomz Sgd/bam2S1/0b6ohxduE8I/OhM35F2X3HcdEF/P8LEKPX4vtW/BtaBBunHO5jWrRZDUD qmI1B2vrXMh8xJCA0FUF9IMQ3r3PFsuq9Vqz8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LHeASP5+vsxBDXMOMf/ygQLASUU6jccN+T5LlmzvuUM=; b=foRH6G1Ewuz0E4e/5X5lvBuc4JFvDoPClZCb96igdegjhiDgP6pd70jkG7LKo40xHE anJcG3gJ1EE0XNbskz/HE19jpYgd7vVpAsI1pi5Nmt52zTNSso1YA+dfy0xgO9vYs6ak EDj2s86sCc99sP6yPU+cWiZ5U6vwHRTcIlGVWsLVA2QXhTcWdRmWkpKs+LKgCviHeb2D YZp5o+evCXHP9+PmoMlkpg3LDzAovlw/5vgHJftExAfhD0ypvgTO94nsEZ+B4U6H22v0 b5gF+xrJCsUxwvtpd3AAQyvTpAa+Zyn3XXAelSbx1PJZKhMDKeCFAwh1sku34Edr1939 9Mdw== X-Gm-Message-State: AOAM531WezKDZesZmtxgaIMXCq7dQF1LZ8sLNsxcmWa/FZvTB+T7gYLL EylzGQF/lL95IrOlkJewJnRnwgntibFARQ== X-Google-Smtp-Source: ABdhPJwM/fmWxhpcqOdUHwRI6teWgr0/YElH0APMDzvFKEP9Jy4jUcqWD3a8/t6NoRwDDS2SmMxLWQ== X-Received: by 2002:a17:90a:4306:: with SMTP id q6mr35820817pjg.202.1633342998884; Mon, 04 Oct 2021 03:23:18 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:15ef:e4fd:2730:ca53]) by smtp.gmail.com with ESMTPSA id u12sm15243467pjr.2.2021.10.04.03.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 03:23:16 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 4 Oct 2021 19:23:08 +0900 Message-Id: <20211004102308.3726725-1-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH] lc-compliance: Add test to set test pattern mode 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" This adds the test to verify the requested test pattern mode is correctly applied in request metadata. Signed-off-by: Hirokazu Honda --- src/lc-compliance/capture_test.cpp | 15 ++++ src/lc-compliance/simple_capture.cpp | 101 +++++++++++++++++++++++++++ src/lc-compliance/simple_capture.h | 16 +++++ 3 files changed, 132 insertions(+) diff --git a/src/lc-compliance/capture_test.cpp b/src/lc-compliance/capture_test.cpp index 52578207..fc0b5322 100644 --- a/src/lc-compliance/capture_test.cpp +++ b/src/lc-compliance/capture_test.cpp @@ -121,6 +121,21 @@ TEST_P(SingleStream, UnbalancedStop) capture.capture(numRequests); } +TEST_P(SingleStream, TestPatternMode) +{ + auto [role, numRequests] = GetParam(); + + SimpleCaptureTestPatternMode capture(camera_); + capture.configure(role); + + auto testPatternModes = capture.availableTestPatternModes(); + if (testPatternModes.empty()) + return; + + for (const int32_t testPatternMode : testPatternModes) + capture.capture(testPatternMode, numRequests); +} + INSTANTIATE_TEST_SUITE_P(CaptureTests, SingleStream, testing::Combine(testing::ValuesIn(ROLES), diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp index ab5cb35c..f279b6a7 100644 --- a/src/lc-compliance/simple_capture.cpp +++ b/src/lc-compliance/simple_capture.cpp @@ -189,3 +189,104 @@ void SimpleCaptureUnbalanced::requestComplete(Request *request) if (camera_->queueRequest(request)) loop_->exit(-EINVAL); } + +/* SimpleCaptureTestPatternMode */ + +SimpleCaptureTestPatternMode::SimpleCaptureTestPatternMode(std::shared_ptr camera) + : SimpleCapture(camera) +{ +} + +std::vector SimpleCaptureTestPatternMode::availableTestPatternModes() const +{ + const auto &controls = camera_->controls(); + const auto it = controls.find(&controls::draft::TestPatternMode); + if (it == controls.end()) + return {}; + + std::vector testPatternModes; + const std::vector &values = it->second.values(); + for (const auto &value : values) + testPatternModes.push_back(value.get()); + + return testPatternModes; +} + +void SimpleCaptureTestPatternMode::capture(int32_t testPatternMode, + unsigned int numRequests) +{ + start(); + + Stream *stream = config_->at(0).stream(); + const std::vector> &buffers = allocator_->buffers(stream); + /* No point in testing less requests then the camera depth. */ + if (buffers.size() > numRequests) { + std::cout << "Camera needs " << buffers.size() + << " requests, can't test only " + << numRequests << std::endl; + GTEST_SKIP(); + } + + captureCount_ = 0; + captureLimit_ = numRequests; + testPatternMode_ = testPatternMode; + + /* Queue the recommended number of reqeuests. */ + std::vector> requests; + for (const std::unique_ptr &buffer : buffers) { + std::unique_ptr request = camera_->createRequest(); + ASSERT_TRUE(request) << "Can't create request"; + + request->controls().set(controls::draft::TestPatternMode, + testPatternMode); + + ASSERT_EQ(request->addBuffer(stream, buffer.get()), 0) << "Can't set buffer for request"; + + ASSERT_EQ(camera_->queueRequest(request.get()), 0) << "Failed to queue request"; + + requests.push_back(std::move(request)); + } + + /* Run capture session. */ + loop_ = new EventLoop(); + int status = loop_->exec(); + stop(); + delete loop_; + + ASSERT_EQ(status, 0); +} + +void SimpleCaptureTestPatternMode::requestComplete(Request *request) +{ + captureCount_++; + if (captureCount_ >= captureLimit_) { + loop_->exit(0); + return; + } + + if (!request->metadata().contains(controls::draft::TestPatternMode)) { + if (testPatternMode_ != controls::draft::TestPatternModeOff) { + std::cerr << "no test pattern mode mismatch: expected=" + << testPatternMode_ << std::endl; + loop_->exit(-EINVAL); + return; + } + } else { + const int32_t testPatternMode = + request->metadata().get(controls::draft::TestPatternMode); + if (testPatternMode_ != testPatternMode) { + std::cerr << "test pattern mode mismatch: expected=" + << testPatternMode_ << ", actual=" + << testPatternMode << std::endl; + + loop_->exit(-EINVAL); + return; + } + } + + request->reuse(Request::ReuseBuffers); + request->controls().set(controls::draft::TestPatternMode, + testPatternMode_); + if (camera_->queueRequest(request)) + loop_->exit(-EINVAL); +} diff --git a/src/lc-compliance/simple_capture.h b/src/lc-compliance/simple_capture.h index 100ffd66..7989a308 100644 --- a/src/lc-compliance/simple_capture.h +++ b/src/lc-compliance/simple_capture.h @@ -64,4 +64,20 @@ private: unsigned int captureLimit_; }; +class SimpleCaptureTestPatternMode : public SimpleCapture +{ +public: + SimpleCaptureTestPatternMode(std::shared_ptr camera); + + std::vector availableTestPatternModes() const; + void capture(int32_t testPatternMode, unsigned int numRequests); + +private: + void requestComplete(libcamera::Request *request) override; + + unsigned int captureCount_; + unsigned int captureLimit_; + int32_t testPatternMode_; +}; + #endif /* __LC_COMPLIANCE_SIMPLE_CAPTURE_H__ */