Show a patch.

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

{
    "id": 2169,
    "url": "https://patchwork.libcamera.org/api/patches/2169/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2169/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20191012184407.31684-9-laurent.pinchart@ideasonboard.com>",
    "date": "2019-10-12T18:44:01",
    "name": "[libcamera-devel,v2,08/14] test: v4l2_videodevice: Add V4L2 control test",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b9691963577b831af28a47155e2a88ffe3d7f2c6",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2169/mbox/",
    "series": [
        {
            "id": 531,
            "url": "https://patchwork.libcamera.org/api/series/531/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=531",
            "date": "2019-10-12T18:43:53",
            "name": "Use ControlList for both libcamera and V4L2 controls",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/531/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2169/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2169/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E7E361986\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Oct 2019 20:44:21 +0200 (CEST)",
            "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F228C33A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Oct 2019 20:44:20 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570905861;\n\tbh=sG7Ifl84SxV6o5oFM/Kb4BddvDTqdPqV0WkoKLzi/8E=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=YvZqbOQo6x9OKjCQhUVxvV/E33yZZsEW8nn0CrvWfPpRKS1wjnYNFA4k1J/do49q1\n\tOalPgxql7qsU0jY+muIigfHpEaws/cQsDf8HgsDkujdJ1TFO2ZEGWsJ3W7aUl/hUDF\n\tV5zRf9yID98YiLfaH3ESpfMOsWDr4vvhRm1nrDR8=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 12 Oct 2019 21:44:01 +0300",
        "Message-Id": "<20191012184407.31684-9-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20191012184407.31684-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20191012184407.31684-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 08/14] test: v4l2_videodevice: Add V4L2\n\tcontrol test",
        "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>",
        "X-List-Received-Date": "Sat, 12 Oct 2019 18:44:21 -0000"
    },
    "content": "Add a test that exercises the control enumeration, get and set APIs on a\nV4L2Device.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/v4l2_videodevice/controls.cpp | 98 ++++++++++++++++++++++++++++++\n test/v4l2_videodevice/meson.build  |  1 +\n 2 files changed, 99 insertions(+)\n create mode 100644 test/v4l2_videodevice/controls.cpp",
    "diff": "diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp\nnew file mode 100644\nindex 000000000000..4a7535245c00\n--- /dev/null\n+++ b/test/v4l2_videodevice/controls.cpp\n@@ -0,0 +1,98 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * controls.cpp - V4L2 device controls handling test\n+ */\n+\n+#include <climits>\n+#include <iostream>\n+\n+#include \"v4l2_videodevice.h\"\n+\n+#include \"v4l2_videodevice_test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class V4L2ControlTest : public V4L2VideoDeviceTest\n+{\n+public:\n+\tV4L2ControlTest()\n+\t\t: V4L2VideoDeviceTest(\"vivid\", \"vivid-000-vid-cap\") {}\n+\n+protected:\n+\tint run()\n+\t{\n+\t\tconst V4L2ControlInfoMap &info = capture_->controls();\n+\n+\t\t/* Test control enumeration. */\n+\t\tif (info.empty()) {\n+\t\t\tcerr << \"Failed to enumerate controls\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (info.find(V4L2_CID_BRIGHTNESS) == info.end() ||\n+\t\t    info.find(V4L2_CID_CONTRAST) == info.end() ||\n+\t\t    info.find(V4L2_CID_SATURATION) == info.end()) {\n+\t\t\tcerr << \"Missing controls\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tconst V4L2ControlInfo &brightness = info.find(V4L2_CID_BRIGHTNESS)->second;\n+\t\tconst V4L2ControlInfo &contrast = info.find(V4L2_CID_CONTRAST)->second;\n+\t\tconst V4L2ControlInfo &saturation = info.find(V4L2_CID_SATURATION)->second;\n+\n+\t\t/* Test getting controls. */\n+\t\tV4L2ControlList ctrls;\n+\t\tctrls.add(V4L2_CID_BRIGHTNESS);\n+\t\tctrls.add(V4L2_CID_CONTRAST);\n+\t\tctrls.add(V4L2_CID_SATURATION);\n+\n+\t\tint ret = capture_->getControls(&ctrls);\n+\t\tif (ret != 0) {\n+\t\t\tcerr << \"Failed to get controls\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (ctrls[V4L2_CID_BRIGHTNESS]->value().get<int32_t>() == -1 ||\n+\t\t    ctrls[V4L2_CID_CONTRAST]->value().get<int32_t>() == -1 ||\n+\t\t    ctrls[V4L2_CID_SATURATION]->value().get<int32_t>() == -1) {\n+\t\t\tcerr << \"Incorrect value for retrieved controls\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test setting controls. */\n+\t\tctrls[V4L2_CID_BRIGHTNESS]->value() = brightness.range().min();\n+\t\tctrls[V4L2_CID_CONTRAST]->value() = contrast.range().max();\n+\t\tctrls[V4L2_CID_SATURATION]->value() = saturation.range().min();\n+\n+\t\tret = capture_->setControls(&ctrls);\n+\t\tif (ret != 0) {\n+\t\t\tcerr << \"Failed to set controls\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test setting controls outside of range. */\n+\t\tctrls[V4L2_CID_BRIGHTNESS]->value() = brightness.range().min().get<int32_t>() - 1;\n+\t\tctrls[V4L2_CID_CONTRAST]->value() = contrast.range().max().get<int32_t>() + 1;\n+\t\tctrls[V4L2_CID_SATURATION]->value() = saturation.range().min().get<int32_t>() + 1;\n+\n+\t\tret = capture_->setControls(&ctrls);\n+\t\tif (ret != 0) {\n+\t\t\tcerr << \"Failed to set controls (out of range)\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (ctrls[V4L2_CID_BRIGHTNESS]->value() != brightness.range().min() ||\n+\t\t    ctrls[V4L2_CID_CONTRAST]->value() != brightness.range().max() ||\n+\t\t    ctrls[V4L2_CID_SATURATION]->value() != saturation.range().min().get<int32_t>() + 1) {\n+\t\t\tcerr << \"Controls not updated when set\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(V4L2ControlTest);\ndiff --git a/test/v4l2_videodevice/meson.build b/test/v4l2_videodevice/meson.build\nindex ad41898b5f8b..5c52da7219c2 100644\n--- a/test/v4l2_videodevice/meson.build\n+++ b/test/v4l2_videodevice/meson.build\n@@ -2,6 +2,7 @@\n # They are not alphabetically sorted.\n v4l2_videodevice_tests = [\n     [ 'double_open',        'double_open.cpp' ],\n+    [ 'controls',           'controls.cpp' ],\n     [ 'formats',            'formats.cpp' ],\n     [ 'request_buffers',    'request_buffers.cpp' ],\n     [ 'stream_on_off',      'stream_on_off.cpp' ],\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "08/14"
    ]
}