Patch Detail
Show a patch.
GET /api/patches/79/?format=api
{ "id": 79, "url": "https://patchwork.libcamera.org/api/patches/79/?format=api", "web_url": "https://patchwork.libcamera.org/patch/79/", "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": "<20181222230041.29999-4-niklas.soderlund@ragnatech.se>", "date": "2018-12-22T23:00:32", "name": "[libcamera-devel,03/12] libcamera: deviceenumerator: add DeviceInfo class", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "ff2cbb0ffa734bde0e611a6c9264c74e47f46b48", "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/79/mbox/", "series": [ { "id": 38, "url": "https://patchwork.libcamera.org/api/series/38/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=38", "date": "2018-12-22T23:00:29", "name": "Add basic camera enumeration", "version": 1, "mbox": "https://patchwork.libcamera.org/series/38/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/79/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/79/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 582E360B2D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 23 Dec 2018 00:02:21 +0100 (CET)", "from wyvern.dyn.berto.se (unknown [217.31.177.236])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 92559c6b-063d-11e9-9adf-005056917a89;\n\tSun, 23 Dec 2018 00:01:54 +0100 (CET)" ], "X-Halon-ID": "92559c6b-063d-11e9-9adf-005056917a89", "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": "Sun, 23 Dec 2018 00:00:32 +0100", "Message-Id": "<20181222230041.29999-4-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20181222230041.29999-1-niklas.soderlund@ragnatech.se>", "References": "<20181222230041.29999-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 03/12] libcamera: deviceenumerator: add\n\tDeviceInfo 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, 22 Dec 2018 23:02:21 -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>\n---\n src/libcamera/deviceenumerator.cpp | 78 ++++++++++++++++++++++++\n src/libcamera/include/deviceenumerator.h | 44 +++++++++++++\n src/libcamera/meson.build | 2 +\n 3 files changed, 124 insertions(+)\n create mode 100644 src/libcamera/deviceenumerator.cpp\n create mode 100644 src/libcamera/include/deviceenumerator.h", "diff": "diff --git a/src/libcamera/deviceenumerator.cpp b/src/libcamera/deviceenumerator.cpp\nnew file mode 100644\nindex 0000000000000000..7c44a65b45472ef3\n--- /dev/null\n+++ b/src/libcamera/deviceenumerator.cpp\n@@ -0,0 +1,78 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * deviceenumerator.cpp - Enumeration and matching\n+ */\n+\n+#include \"deviceenumerator.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+bool 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 do not exist\";\n+\t\treturn false;\n+\t}\n+\n+\tdevnode = it->second;\n+\treturn true;\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/include/deviceenumerator.h b/src/libcamera/include/deviceenumerator.h\nnew file mode 100644\nindex 0000000000000000..0136ed6ea23bf65e\n--- /dev/null\n+++ b/src/libcamera/include/deviceenumerator.h\n@@ -0,0 +1,44 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * deviceenumerator.h - API to enumerate and find media devices\n+ */\n+#ifndef __LIBCAMERA_DEVICEENUMERATE_H__\n+#define __LIBCAMERA_DEVICEENUMERATE_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+\tbool 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_DEVICEENUMERATE_H__ */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 52b556a8ed4050cb..17cdf06dd2bedfb3 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+ 'deviceenumerator.cpp',\n 'log.cpp',\n 'main.cpp',\n ])\n \n libcamera_headers = files([\n+ 'include/deviceenumerator.h',\n 'include/log.h',\n 'include/utils.h',\n ])\n", "prefixes": [ "libcamera-devel", "03/12" ] }