Show a patch.

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

{
    "id": 1394,
    "url": "https://patchwork.libcamera.org/api/patches/1394/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1394/",
    "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": "<20190611132657.22133-1-laurent.pinchart@ideasonboard.com>",
    "date": "2019-06-11T13:26:57",
    "name": "[libcamera-devel] tests: Add CameraSensor class test",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "25776bf8be3dd5d325c09758c95022f5e40d7054",
    "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/1394/mbox/",
    "series": [
        {
            "id": 349,
            "url": "https://patchwork.libcamera.org/api/series/349/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=349",
            "date": "2019-06-11T13:26:57",
            "name": "[libcamera-devel] tests: Add CameraSensor class test",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/349/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1394/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1394/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C41762F96\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 11 Jun 2019 15:27:16 +0200 (CEST)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A923AFA0;\n\tTue, 11 Jun 2019 15:27:15 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560259635;\n\tbh=DS0Sm+7xoEgTq5N2DufpHsPB685bG8WRa58eqSc4Pm0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=fpqRQHyxMOrKbqMaRe4BBPj23R0MRVW0hYkIRK8QyE56kmL5HvasUmY6kouMLHxSZ\n\teIW/1VDfZmbvtVP4ZsHYFZRHMROBTcB6jEtFPyB90Dw6NfRo2EaRv4gKtzWPwA/fsz\n\tLDvsKVWUXwFdizip0tWLuZcfIXMUbazQhB4ErKcw=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Mickael Guene <mickael.guene@st.com>,\n\tJacopo Mondi <jacopo@jmondi.org>",
        "Date": "Tue, 11 Jun 2019 16:26:57 +0300",
        "Message-Id": "<20190611132657.22133-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<1560253031-98823-1-git-send-email-mickael.guene@st.com>",
        "References": "<1560253031-98823-1-git-send-email-mickael.guene@st.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] tests: Add CameraSensor class test",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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": "Tue, 11 Jun 2019 13:27:16 -0000"
    },
    "content": "Add a test to verify media bus codes, sizes and resolution retrieval\nthrough the CameraSensor APÏ based on the Sensor A in the vimc pipeline.\nAlso check that the getFormat() method returns the expected media bus\ncode and size.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/camera-sensor.cpp | 112 +++++++++++++++++++++++++++++++++++++++++\n test/meson.build       |   1 +\n 2 files changed, 113 insertions(+)\n create mode 100644 test/camera-sensor.cpp",
    "diff": "diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp\nnew file mode 100644\nindex 000000000000..5f128906ce0e\n--- /dev/null\n+++ b/test/camera-sensor.cpp\n@@ -0,0 +1,112 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * camera-sensor.cpp - Camera sensor tests\n+ */\n+\n+#include <algorithm>\n+#include <iostream>\n+\n+#include <linux/media-bus-format.h>\n+\n+#include \"camera_sensor.h\"\n+#include \"device_enumerator.h\"\n+#include \"media_device.h\"\n+#include \"v4l2_subdevice.h\"\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class CameraSensorTest : public Test\n+{\n+protected:\n+\tint init()\n+\t{\n+\t\tenumerator_ = DeviceEnumerator::create();\n+\t\tif (!enumerator_) {\n+\t\t\tcerr << \"Failed to create device enumerator\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (enumerator_->enumerate()) {\n+\t\t\tcerr << \"Failed to enumerate media devices\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tDeviceMatch dm(\"vimc\");\n+\t\tmedia_ = enumerator_->search(dm);\n+\t\tif (!media_) {\n+\t\t\tcerr << \"Unable to find \\'vimc\\' media device node\" << endl;\n+\t\t\treturn TestSkip;\n+\t\t}\n+\n+\t\tMediaEntity *entity = media_->getEntityByName(\"Sensor A\");\n+\t\tif (!entity) {\n+\t\t\tcerr << \"Unable to find media entity 'Sensor A'\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tsensor_ = new CameraSensor(entity);\n+\t\tif (sensor_->init() < 0) {\n+\t\t\tcerr << \"Unable to initialise camera sensor\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tint run()\n+\t{\n+\t\tconst std::vector<unsigned int> &codes = sensor_->mbusCodes();\n+\t\tauto iter = std::find(codes.begin(), codes.end(),\n+\t\t\t\t      MEDIA_BUS_FMT_ARGB8888_1X32);\n+\t\tif (iter == codes.end()) {\n+\t\t\tcerr << \"Sensor doesn't support ARGB8888_1X32\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tconst std::vector<Size> &sizes = sensor_->sizes();\n+\t\tauto iter2 = std::find(sizes.begin(), sizes.end(),\n+\t\t\t\t       Size(4096, 2160));\n+\t\tif (iter2 == sizes.end()) {\n+\t\t\tcerr << \"Sensor doesn't support 4096x2160\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tconst Size &resolution = sensor_->resolution();\n+\t\tif (resolution != Size(4096, 2160)) {\n+\t\t\tcerr << \"Incorrect sensor resolution \"\n+\t\t\t     << resolution.toString() << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tV4L2SubdeviceFormat format = sensor_->getFormat({MEDIA_BUS_FMT_UYVY8_2X8,\n+\t\t\t\t\t\t\t\t MEDIA_BUS_FMT_SBGGR10_1X10,\n+\t\t\t\t\t\t\t\t MEDIA_BUS_FMT_BGR888_1X24},\n+\t\t\t\t\t\t\t\tSize(1024, 768));\n+\t\tif (format.mbus_code != MEDIA_BUS_FMT_SBGGR10_1X10 ||\n+\t\t    format.size != Size(4096, 2160)) {\n+\t\t\tcerr << \"Failed to get a suitable format, expected 4096x2160-0x\"\n+\t\t\t     << std::hex << MEDIA_BUS_FMT_SBGGR10_1X10\n+\t\t\t     << \", got \" << format.toString() << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup()\n+\t{\n+\t\tdelete sensor_;\n+\t}\n+\n+private:\n+\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n+\tstd::shared_ptr<MediaDevice> media_;\n+\tCameraSensor *sensor_;\n+};\n+\n+TEST_REGISTER(CameraSensorTest)\ndiff --git a/test/meson.build b/test/meson.build\nindex 609aeab80e7d..25f181c20308 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -17,6 +17,7 @@ public_tests = [\n ]\n \n internal_tests = [\n+    ['camera-sensor',                   'camera-sensor.cpp'],\n ]\n \n foreach t : public_tests\n",
    "prefixes": [
        "libcamera-devel"
    ]
}