{"id":99,"url":"https://patchwork.libcamera.org/api/patches/99/?format=json","web_url":"https://patchwork.libcamera.org/patch/99/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","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-5-niklas.soderlund@ragnatech.se>","date":"2018-12-29T03:28:47","name":"[libcamera-devel,v2,04/12] libcamera: device_enumerator: add DeviceMatch class","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a6abdbfc01c61f30bfa155c0b55048f9f92cb06c","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/99/mbox/","series":[{"id":41,"url":"https://patchwork.libcamera.org/api/series/41/?format=json","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/99/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/99/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 1204560B36\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Dec 2018 04:29:54 +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 fa85b787-0b19-11e9-911a-0050569116f7;\n\tSat, 29 Dec 2018 04:29:41 +0100 (CET)"],"X-Halon-ID":"fa85b787-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:47 +0100","Message-Id":"<20181229032855.26249-5-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 04/12] libcamera: device_enumerator:\n\tadd DeviceMatch 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 DeviceMatch class which represents all properties of a media\ndevice a pipeline hander can specify when searching for a device to use\nin its pipeline.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n* Changes since v1\n- Remove unneeded std::string(entity) in DeviceMatch::add().\n- Inline matchInfo() and matchEntities() into the only caller,\n  DeviceMatch::match.\n---\n src/libcamera/device_enumerator.cpp       | 36 +++++++++++++++++++++++\n src/libcamera/include/device_enumerator.h | 14 +++++++++\n 2 files changed, 50 insertions(+)","diff":"diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex 83dcda9403526010..61b32bb921581f49 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -75,4 +75,40 @@ int DeviceInfo::lookup(const std::string &name, std::string &devnode) const\n \treturn 0;\n }\n \n+/* -----------------------------------------------------------------------------\n+ * DeviceMatch\n+ */\n+\n+DeviceMatch::DeviceMatch(const std::string &driver)\n+\t: driver_(driver)\n+{\n+}\n+\n+void DeviceMatch::add(const std::string &entity)\n+{\n+\tentities_.push_back(entity);\n+}\n+\n+bool DeviceMatch::match(const DeviceInfo *info) const\n+{\n+\tif (driver_ != info->info().driver)\n+\t\treturn false;\n+\n+\tfor (const std::string &name : entities_) {\n+\t\tbool found = false;\n+\n+\t\tfor (const std::string &entity : info->entities()) {\n+\t\t\tif (name == entity) {\n+\t\t\t\tfound = true;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (!found)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\nindex ac40bafc5169c7c7..ed1e986ff45f95f5 100644\n--- a/src/libcamera/include/device_enumerator.h\n+++ b/src/libcamera/include/device_enumerator.h\n@@ -39,6 +39,20 @@ private:\n \tstd::map<std::string, std::string> entities_;\n };\n \n+class DeviceMatch\n+{\n+public:\n+\tDeviceMatch(const std::string &driver);\n+\n+\tvoid add(const std::string &entity);\n+\n+\tbool match(const DeviceInfo *info) const;\n+\n+private:\n+\tstd::string driver_;\n+\tstd::vector<std::string> entities_;\n+};\n+\n } /* namespace libcamera */\n \n #endif\t/* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */\n","prefixes":["libcamera-devel","v2","04/12"]}