{"id":14040,"url":"https://patchwork.libcamera.org/api/1.1/patches/14040/?format=json","web_url":"https://patchwork.libcamera.org/patch/14040/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211004102308.3726725-1-hiroh@chromium.org>","date":"2021-10-04T10:23:08","name":"[libcamera-devel,RFC] lc-compliance: Add test to set test pattern mode","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"65ba4173df62e58a8592dbf6d67e8d3814293ee5","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14040/mbox/","series":[{"id":2598,"url":"https://patchwork.libcamera.org/api/1.1/series/2598/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2598","date":"2021-10-04T10:23:08","name":"[libcamera-devel,RFC] lc-compliance: Add test to set test pattern mode","version":1,"mbox":"https://patchwork.libcamera.org/series/2598/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14040/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14040/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 979B7C3243\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  4 Oct 2021 10:23:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 19038691B6;\n\tMon,  4 Oct 2021 12:23:23 +0200 (CEST)","from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com\n\t[IPv6:2607:f8b0:4864:20::1033])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B3946023F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  4 Oct 2021 12:23:21 +0200 (CEST)","by mail-pj1-x1033.google.com with SMTP id\n\trj12-20020a17090b3e8c00b0019f88e44d85so5259614pjb.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 04 Oct 2021 03:23:21 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:15ef:e4fd:2730:ca53])\n\tby smtp.gmail.com with ESMTPSA id\n\tu12sm15243467pjr.2.2021.10.04.03.23.15\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 04 Oct 2021 03:23:16 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"GcjNqGV+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=LHeASP5+vsxBDXMOMf/ygQLASUU6jccN+T5LlmzvuUM=;\n\tb=GcjNqGV+e0MbQA4NefXR0QcoTeJoGJDspwkcg3q6t+ZKYPbBPLBXSxpBemQtRzOomz\n\tSgd/bam2S1/0b6ohxduE8I/OhM35F2X3HcdEF/P8LEKPX4vtW/BtaBBunHO5jWrRZDUD\n\tqmI1B2vrXMh8xJCA0FUF9IMQ3r3PFsuq9Vqz8=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=LHeASP5+vsxBDXMOMf/ygQLASUU6jccN+T5LlmzvuUM=;\n\tb=foRH6G1Ewuz0E4e/5X5lvBuc4JFvDoPClZCb96igdegjhiDgP6pd70jkG7LKo40xHE\n\tanJcG3gJ1EE0XNbskz/HE19jpYgd7vVpAsI1pi5Nmt52zTNSso1YA+dfy0xgO9vYs6ak\n\tEDj2s86sCc99sP6yPU+cWiZ5U6vwHRTcIlGVWsLVA2QXhTcWdRmWkpKs+LKgCviHeb2D\n\tYZp5o+evCXHP9+PmoMlkpg3LDzAovlw/5vgHJftExAfhD0ypvgTO94nsEZ+B4U6H22v0\n\tb5gF+xrJCsUxwvtpd3AAQyvTpAa+Zyn3XXAelSbx1PJZKhMDKeCFAwh1sku34Edr1939\n\t9Mdw==","X-Gm-Message-State":"AOAM531WezKDZesZmtxgaIMXCq7dQF1LZ8sLNsxcmWa/FZvTB+T7gYLL\n\tEylzGQF/lL95IrOlkJewJnRnwgntibFARQ==","X-Google-Smtp-Source":"ABdhPJwM/fmWxhpcqOdUHwRI6teWgr0/YElH0APMDzvFKEP9Jy4jUcqWD3a8/t6NoRwDDS2SmMxLWQ==","X-Received":"by 2002:a17:90a:4306:: with SMTP id\n\tq6mr35820817pjg.202.1633342998884; \n\tMon, 04 Oct 2021 03:23:18 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH] lc-compliance: Add test to set test\n\tpattern mode","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This adds the test to verify the requested test pattern mode is\ncorrectly applied in request metadata.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/lc-compliance/capture_test.cpp   |  15 ++++\n src/lc-compliance/simple_capture.cpp | 101 +++++++++++++++++++++++++++\n src/lc-compliance/simple_capture.h   |  16 +++++\n 3 files changed, 132 insertions(+)","diff":"diff --git a/src/lc-compliance/capture_test.cpp b/src/lc-compliance/capture_test.cpp\nindex 52578207..fc0b5322 100644\n--- a/src/lc-compliance/capture_test.cpp\n+++ b/src/lc-compliance/capture_test.cpp\n@@ -121,6 +121,21 @@ TEST_P(SingleStream, UnbalancedStop)\n \tcapture.capture(numRequests);\n }\n \n+TEST_P(SingleStream, TestPatternMode)\n+{\n+\tauto [role, numRequests] = GetParam();\n+\n+\tSimpleCaptureTestPatternMode capture(camera_);\n+\tcapture.configure(role);\n+\n+\tauto testPatternModes = capture.availableTestPatternModes();\n+\tif (testPatternModes.empty())\n+\t\treturn;\n+\n+\tfor (const int32_t testPatternMode : testPatternModes)\n+\t\tcapture.capture(testPatternMode, numRequests);\n+}\n+\n INSTANTIATE_TEST_SUITE_P(CaptureTests,\n \t\t\t SingleStream,\n \t\t\t testing::Combine(testing::ValuesIn(ROLES),\ndiff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\nindex ab5cb35c..f279b6a7 100644\n--- a/src/lc-compliance/simple_capture.cpp\n+++ b/src/lc-compliance/simple_capture.cpp\n@@ -189,3 +189,104 @@ void SimpleCaptureUnbalanced::requestComplete(Request *request)\n \tif (camera_->queueRequest(request))\n \t\tloop_->exit(-EINVAL);\n }\n+\n+/* SimpleCaptureTestPatternMode */\n+\n+SimpleCaptureTestPatternMode::SimpleCaptureTestPatternMode(std::shared_ptr<Camera> camera)\n+\t: SimpleCapture(camera)\n+{\n+}\n+\n+std::vector<int32_t> SimpleCaptureTestPatternMode::availableTestPatternModes() const\n+{\n+\tconst auto &controls = camera_->controls();\n+\tconst auto it = controls.find(&controls::draft::TestPatternMode);\n+\tif (it == controls.end())\n+\t\treturn {};\n+\n+\tstd::vector<int32_t> testPatternModes;\n+\tconst std::vector<ControlValue> &values = it->second.values();\n+\tfor (const auto &value : values)\n+\t\ttestPatternModes.push_back(value.get<int32_t>());\n+\n+\treturn testPatternModes;\n+}\n+\n+void SimpleCaptureTestPatternMode::capture(int32_t testPatternMode,\n+\t\t\t\t\t   unsigned int numRequests)\n+{\n+\tstart();\n+\n+\tStream *stream = config_->at(0).stream();\n+\tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers = allocator_->buffers(stream);\n+\t/* No point in testing less requests then the camera depth. */\n+\tif (buffers.size() > numRequests) {\n+\t\tstd::cout << \"Camera needs \" << buffers.size()\n+\t\t\t  << \" requests, can't test only \"\n+\t\t\t  << numRequests << std::endl;\n+\t\tGTEST_SKIP();\n+\t}\n+\n+\tcaptureCount_ = 0;\n+\tcaptureLimit_ = numRequests;\n+\ttestPatternMode_ = testPatternMode;\n+\n+\t/* Queue the recommended number of reqeuests. */\n+\tstd::vector<std::unique_ptr<libcamera::Request>> requests;\n+\tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers) {\n+\t\tstd::unique_ptr<Request> request = camera_->createRequest();\n+\t\tASSERT_TRUE(request) << \"Can't create request\";\n+\n+\t\trequest->controls().set(controls::draft::TestPatternMode,\n+\t\t\t\t\ttestPatternMode);\n+\n+\t\tASSERT_EQ(request->addBuffer(stream, buffer.get()), 0) << \"Can't set buffer for request\";\n+\n+\t\tASSERT_EQ(camera_->queueRequest(request.get()), 0) << \"Failed to queue request\";\n+\n+\t\trequests.push_back(std::move(request));\n+\t}\n+\n+\t/* Run capture session. */\n+\tloop_ = new EventLoop();\n+\tint status = loop_->exec();\n+\tstop();\n+\tdelete loop_;\n+\n+\tASSERT_EQ(status, 0);\n+}\n+\n+void SimpleCaptureTestPatternMode::requestComplete(Request *request)\n+{\n+\tcaptureCount_++;\n+\tif (captureCount_ >= captureLimit_) {\n+\t\tloop_->exit(0);\n+\t\treturn;\n+\t}\n+\n+\tif (!request->metadata().contains(controls::draft::TestPatternMode)) {\n+\t\tif (testPatternMode_ != controls::draft::TestPatternModeOff) {\n+\t\t\tstd::cerr << \"no test pattern mode mismatch: expected=\"\n+\t\t\t\t  << testPatternMode_ << std::endl;\n+\t\t\tloop_->exit(-EINVAL);\n+\t\t\treturn;\n+\t\t}\n+\t} else {\n+\t\tconst int32_t testPatternMode =\n+\t\t\trequest->metadata().get(controls::draft::TestPatternMode);\n+\t\tif (testPatternMode_ != testPatternMode) {\n+\t\t\tstd::cerr << \"test pattern mode mismatch: expected=\"\n+\t\t\t\t  << testPatternMode_ << \", actual=\"\n+\t\t\t\t  << testPatternMode << std::endl;\n+\n+\t\t\tloop_->exit(-EINVAL);\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\n+\trequest->reuse(Request::ReuseBuffers);\n+\trequest->controls().set(controls::draft::TestPatternMode,\n+\t\t\t\ttestPatternMode_);\n+\tif (camera_->queueRequest(request))\n+\t\tloop_->exit(-EINVAL);\n+}\ndiff --git a/src/lc-compliance/simple_capture.h b/src/lc-compliance/simple_capture.h\nindex 100ffd66..7989a308 100644\n--- a/src/lc-compliance/simple_capture.h\n+++ b/src/lc-compliance/simple_capture.h\n@@ -64,4 +64,20 @@ private:\n \tunsigned int captureLimit_;\n };\n \n+class SimpleCaptureTestPatternMode : public SimpleCapture\n+{\n+public:\n+\tSimpleCaptureTestPatternMode(std::shared_ptr<libcamera::Camera> camera);\n+\n+\tstd::vector<int32_t> availableTestPatternModes() const;\n+\tvoid capture(int32_t testPatternMode, unsigned int numRequests);\n+\n+private:\n+\tvoid requestComplete(libcamera::Request *request) override;\n+\n+\tunsigned int captureCount_;\n+\tunsigned int captureLimit_;\n+\tint32_t testPatternMode_;\n+};\n+\n #endif /* __LC_COMPLIANCE_SIMPLE_CAPTURE_H__ */\n","prefixes":["libcamera-devel","RFC"]}