Show a patch.

GET /api/1.1/patches/14493/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14493,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14493/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14493/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20211005054027.688044-1-hiroh@chromium.org>",
    "date": "2021-10-05T05:40:27",
    "name": "[libcamera-devel,RFC,v2] lc-compliance: Add test to set test pattern mode",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "90afe24321662e4d62311498b14a8077a8f0ec04",
    "submitter": {
        "id": 63,
        "url": "https://patchwork.libcamera.org/api/1.1/people/63/?format=api",
        "name": "Hirokazu Honda",
        "email": "hiroh@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14493/mbox/",
    "series": [
        {
            "id": 2698,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2698/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2698",
            "date": "2021-10-05T05:40:27",
            "name": "[libcamera-devel,RFC,v2] lc-compliance: Add test to set test pattern mode",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2698/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14493/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14493/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": [
            "parsemail@patchwork.libcamera.org",
            "kbingham@ideasonboard.com"
        ],
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D2ED6BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Nov 2021 17:40:47 +0000 (UTC)",
            "from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net\n\t[86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 569AD501\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Nov 2021 18:40:47 +0100 (CET)",
            "from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id yKkYEVXlW2H7WQAA4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Tue, 05 Oct 2021 07:40:37 +0200",
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[IPv6:2001:4b98:dc0:43:216:3eff:fe33:f827])\tby\n\tperceval.ideasonboard.com (Postfix) with ESMTPS id 2325425B;\n\tTue,  5 Oct 2021 07:40:37 +0200 (CEST)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8A5F6691B8;\n\tTue,  5 Oct 2021 07:40:36 +0200 (CEST)",
            "from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com\n\t[IPv6:2607:f8b0:4864:20::62b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2576D6023D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Oct 2021 07:40:35 +0200 (CEST)",
            "by mail-pl1-x62b.google.com with SMTP id x8so1514797plv.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 04 Oct 2021 22:40:35 -0700 (PDT)",
            "from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:debc:d0db:3bd8:f961])\n\tby smtp.gmail.com with ESMTPSA id\n\te20sm16309581pfc.11.2021.10.04.22.40.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 04 Oct 2021 22:40:32 -0700 (PDT)"
        ],
        "Authentication-Results": [
            "perceval.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=\"IWN4iFH8\"; dkim-atps=neutral",
            "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature\n\tverification failed\" (1024-bit key; unprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"IWN4iFH8\";\tdkim-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=W0jUU9MNQbwRMBCjneLvhD881RbhbYVXd4f3lblf084=; \n\tb=IWN4iFH8i0XNJEbvxZxhlmrHl984OtC7F6qd4CsGAieOLKqORw2RiBRpsrhg0Aw+Wf\n\tX+hXVWeiAxhogqvQt8WSL5tvis3bQPrWhUs5Lvpd/5c1Yw6NaQYl6BiCmYrxXFm4EbOf\n\tRhnHG0D1b47BSYE22fJlkSMsZoD88jAqpoin4=",
        "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=W0jUU9MNQbwRMBCjneLvhD881RbhbYVXd4f3lblf084=;\n\tb=bg4haxnN/KABmC0ZFgjnCVirmicYNjXpJ/GRse23QF3LemCXnsoPa1btXqK9SD0MZQ\n\ti7skGFuC2Y5MxaUOGf+fjvmuV3c75f7KPohar8yDeqCEr7fAloyH3XOC8D2coouk4OI6\n\tS4LYbKmL12NhPGgN7dMpwViZkvFs9FU9PJQV7XKG9KhHmD3rHKEA0JwxxqDkOtWKoMAO\n\tgDzvpoiBxvcG1dVpbmbA2VzE/saN8Vtp4KEOPinNipRHwOdg8yKjQD8WSiMryu/28wFX\n\tB/t/tr/kVqCXRhHBbJMVh0/ErOimQIbmm2p7TXNuXGBDmrpfezfUIxjVP6veYObCzJGm\n\tJf9w==",
        "X-Gm-Message-State": "AOAM531d0laGglnVf2pwKelqApYFXI0JOZYUY4mGMUdMS0MTcM5YJHFt\n\tYJJQ85WbtHIW4Lt3JAcNG7EeVgBvLah+lg==",
        "X-Google-Smtp-Source": "=?utf-8?q?ABdhPJyEftznEgSmM+EDkERhHt1dPrab798XZQfRd?=\n\t=?utf-8?q?RCd50Z4QrsN8kBtaJv9pk9Y9SK8Zp0EW2RhtA=3D=3D?=",
        "X-Received": "by 2002:a17:90a:4b4d:: with SMTP id\n\to13mr1508239pjl.236.1633412433142; \n\tMon, 04 Oct 2021 22:40:33 -0700 (PDT)",
        "From": "Hirokazu Honda <hiroh@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  5 Oct 2021 14:40:27 +0900",
        "Message-Id": "<20211005054027.688044-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 v2] lc-compliance: Add test to set\n\ttest pattern 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>",
        "X-TUID": "zwJfEiUBGBtL",
        "Resent-From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Resent-To": "parsemail@patchwork.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/meson.build                |   1 +\n src/lc-compliance/test_pattern_mode_test.cpp | 157 +++++++++++++++++++\n 2 files changed, 158 insertions(+)\n create mode 100644 src/lc-compliance/test_pattern_mode_test.cpp",
    "diff": "diff --git a/src/lc-compliance/meson.build b/src/lc-compliance/meson.build\nindex aa5852f6..0fd280df 100644\n--- a/src/lc-compliance/meson.build\n+++ b/src/lc-compliance/meson.build\n@@ -17,6 +17,7 @@ lc_compliance_sources = files([\n     'main.cpp',\n     'simple_capture.cpp',\n     'capture_test.cpp',\n+    'test_pattern_mode_test.cpp',\n ])\n \n lc_compliance  = executable('lc-compliance', lc_compliance_sources,\ndiff --git a/src/lc-compliance/test_pattern_mode_test.cpp b/src/lc-compliance/test_pattern_mode_test.cpp\nnew file mode 100644\nindex 00000000..d8599b64\n--- /dev/null\n+++ b/src/lc-compliance/test_pattern_mode_test.cpp\n@@ -0,0 +1,157 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ * Copyright (C) 2021, Collabora Ltd.\n+ *\n+ * test_pattern_mode_test.cpp - Test a capture with a test pattern mode\n+ */\n+\n+#include <libcamera/libcamera.h>\n+\n+#include <gtest/gtest.h>\n+\n+#include \"environment.h\"\n+#include \"simple_capture.h\"\n+\n+using namespace libcamera;\n+\n+namespace {\n+/*\n+ * SimpleCaptureTestPatternMode verifies captures with a test pattern mode. It\n+ * checks the request has the specified test pattern mode in the metadata, but\n+ * doesn't verify the capture content.\n+ */\n+class SimpleCaptureTestPatternMode : public SimpleCapture\n+{\n+public:\n+\tSimpleCaptureTestPatternMode(std::shared_ptr<Camera> camera);\n+\n+\tstd::vector<int32_t> availableTestPatternModes() const;\n+\tvoid capture(int32_t testPatternMode);\n+\n+private:\n+\tvoid requestComplete(Request *request) override;\n+\n+\tunsigned int captureCount_;\n+\tunsigned int captureLimit_;\n+\tint32_t testPatternMode_;\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+{\n+\tstart();\n+\n+\tStream *stream = config_->at(0).stream();\n+\tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers = allocator_->buffers(stream);\n+\tASSERT_FALSE(buffers.empty());\n+\n+\tcaptureCount_ = 0;\n+\tcaptureLimit_ = buffers.size();\n+\ttestPatternMode_ = testPatternMode;\n+\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)\n+\t\t\t<< \"Can't set buffer for request\";\n+\n+\t\tASSERT_EQ(camera_->queueRequest(request.get()), 0)\n+\t\t\t<< \"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+}\n+} /* namespace */\n+\n+TEST(TestPatternModeTest, SetTestPatternMode)\n+{\n+\tEnvironment *env = Environment::get();\n+\n+\tauto camera = env->cm()->get(env->cameraId());\n+\tASSERT_TRUE(camera);\n+\tASSERT_EQ(camera->acquire(), 0);\n+\n+\tSimpleCaptureTestPatternMode capture(camera);\n+\tcapture.configure(StreamRole::Viewfinder);\n+\n+\tauto testPatternModes = capture.availableTestPatternModes();\n+\tif (testPatternModes.empty()) {\n+\t\tcamera->release();\n+\t\tGTEST_SKIP() << \"No test pattern is available\";\n+\t}\n+\n+\tfor (const int32_t testPatternMode : testPatternModes)\n+\t\tcapture.capture(testPatternMode);\n+\n+\tcamera->release();\n+}\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "v2"
    ]
}