Show a patch.

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

{
    "id": 98,
    "url": "https://patchwork.libcamera.org/api/patches/98/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/98/",
    "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": "<20181229032855.26249-4-niklas.soderlund@ragnatech.se>",
    "date": "2018-12-29T03:28:46",
    "name": "[libcamera-devel,v2,03/12] libcamera: device_enumerator: add DeviceInfo class",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f11269f43dc366fbf66f5f93a477de495a6df4a4",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/98/mbox/",
    "series": [
        {
            "id": 41,
            "url": "https://patchwork.libcamera.org/api/series/41/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=41",
            "date": "2018-12-29T03:28:43",
            "name": "Add basic camera enumeration",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/41/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/98/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/98/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 844F760B36\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Dec 2018 04:29:53 +0100 (CET)",
            "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid fa0c59bc-0b19-11e9-911a-0050569116f7;\n\tSat, 29 Dec 2018 04:29:41 +0100 (CET)"
        ],
        "X-Halon-ID": "fa0c59bc-0b19-11e9-911a-0050569116f7",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 29 Dec 2018 04:28:46 +0100",
        "Message-Id": "<20181229032855.26249-4-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20181229032855.26249-1-niklas.soderlund@ragnatech.se>",
        "References": "<20181229032855.26249-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 03/12] libcamera: device_enumerator:\n\tadd DeviceInfo class",
        "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": "Sat, 29 Dec 2018 03:29:54 -0000"
    },
    "content": "Provide a DeviceInfo class which holds all information from the initial\nenumeration of a media device. Not all information available at a media\ndevice is stored, only the information needed for a pipeline handler to\nfind a specific device.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n* Changes since v1\n- s/do/does in DeviceInfo::lookup().\n- Fix typo in include guard.\n---\n src/libcamera/device_enumerator.cpp       | 78 +++++++++++++++++++++++\n src/libcamera/include/device_enumerator.h | 44 +++++++++++++\n src/libcamera/meson.build                 |  2 +\n 3 files changed, 124 insertions(+)\n create mode 100644 src/libcamera/device_enumerator.cpp\n create mode 100644 src/libcamera/include/device_enumerator.h",
    "diff": "diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nnew file mode 100644\nindex 0000000000000000..83dcda9403526010\n--- /dev/null\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -0,0 +1,78 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * device_enumerator.cpp - Enumeration and matching\n+ */\n+\n+#include \"device_enumerator.h\"\n+#include \"log.h\"\n+\n+namespace libcamera {\n+\n+/* -----------------------------------------------------------------------------\n+ * DeviceInfo\n+ */\n+\n+DeviceInfo::DeviceInfo(const std::string &devnode, const struct media_device_info &info,\n+\t\t       const std::map<std::string, std::string> &entities)\n+\t: acquired_(false), devnode_(devnode), info_(info), entities_(entities)\n+{\n+\tfor (const auto &entity : entities_)\n+\t\tLOG(Info) << \"Device: \" << devnode_ << \" Entity: '\" << entity.first << \"' -> \" << entity.second;\n+}\n+\n+int DeviceInfo::acquire()\n+{\n+\tif (acquired_)\n+\t\treturn -EBUSY;\n+\n+\tacquired_ = true;\n+\n+\treturn 0;\n+}\n+\n+void DeviceInfo::release()\n+{\n+\tacquired_ = false;\n+}\n+\n+bool DeviceInfo::busy() const\n+{\n+\treturn acquired_;\n+}\n+\n+const std::string &DeviceInfo::devnode() const\n+{\n+\treturn devnode_;\n+}\n+\n+const struct media_device_info &DeviceInfo::info() const\n+{\n+\treturn info_;\n+}\n+\n+std::vector<std::string> DeviceInfo::entities() const\n+{\n+\tstd::vector<std::string> entities;\n+\n+\tfor (const auto &entity : entities_)\n+\t\tentities.push_back(entity.first);\n+\n+\treturn entities;\n+}\n+\n+int DeviceInfo::lookup(const std::string &name, std::string &devnode) const\n+{\n+\tauto it = entities_.find(name);\n+\n+\tif (it == entities_.end()) {\n+\t\tLOG(Error) << \"Trying to lookup entity '\" << name << \"' which does not exist\";\n+\t\treturn -ENODEV;\n+\t}\n+\n+\tdevnode = it->second;\n+\treturn 0;\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\nnew file mode 100644\nindex 0000000000000000..ac40bafc5169c7c7\n--- /dev/null\n+++ b/src/libcamera/include/device_enumerator.h\n@@ -0,0 +1,44 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * device_enumerator.h - API to enumerate and find media devices\n+ */\n+#ifndef __LIBCAMERA_DEVICE_ENUMERATOR_H__\n+#define __LIBCAMERA_DEVICE_ENUMERATOR_H__\n+\n+#include <map>\n+#include <string>\n+#include <vector>\n+\n+#include <linux/media.h>\n+\n+namespace libcamera {\n+\n+class DeviceInfo\n+{\n+public:\n+\tDeviceInfo(const std::string &devnode, const struct media_device_info &info,\n+\t\t   const std::map<std::string, std::string> &entities);\n+\n+\tint acquire();\n+\tvoid release();\n+\tbool busy() const;\n+\n+\tconst std::string &devnode() const;\n+\tconst struct media_device_info &info() const;\n+\tstd::vector<std::string> entities() const;\n+\n+\tint lookup(const std::string &name, std::string &devnode) const;\n+\n+private:\n+\tbool acquired_;\n+\n+\tstd::string devnode_;\n+\tstruct media_device_info info_;\n+\tstd::map<std::string, std::string> entities_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif\t/* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 52b556a8ed4050cb..581da1aa78ebb3ba 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -1,10 +1,12 @@\n libcamera_sources = files([\n     'camera.cpp',\n+    'device_enumerator.cpp',\n     'log.cpp',\n     'main.cpp',\n ])\n \n libcamera_headers = files([\n+    'include/device_enumerator.h',\n     'include/log.h',\n     'include/utils.h',\n ])\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "03/12"
    ]
}