{"id":3790,"url":"https://patchwork.libcamera.org/api/1.1/patches/3790/?format=json","web_url":"https://patchwork.libcamera.org/patch/3790/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200513172950.72685-3-email@uajain.com>","date":"2020-05-13T17:29:58","name":"[libcamera-devel,v2,2/5] libcamera: device_enumerator: Emit a signal when a new device is hotplugged","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"d6fe1ad14fcf5c78ebba03cb9336a33ec6d723cf","submitter":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/people/1/?format=json","name":"Umang Jain","email":"email@uajain.com"},"delegate":{"id":12,"url":"https://patchwork.libcamera.org/api/1.1/users/12/?format=json","username":"uajain","first_name":"Umang","last_name":"Jain","email":"umang.jain@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/3790/mbox/","series":[{"id":903,"url":"https://patchwork.libcamera.org/api/1.1/series/903/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=903","date":"2020-05-13T17:29:57","name":"Introduce UVC hotplug support","version":2,"mbox":"https://patchwork.libcamera.org/series/903/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3790/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3790/checks/","tags":{},"headers":{"Return-Path":"<bounces+15657259-5c31-libcamera-devel=lists.libcamera.org@em7280.uajain.com>","Received":["from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3BB0360DFC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 May 2020 19:29:59 +0200 (CEST)","by filterdrecv-p3las1-cb48d7cc9-6ppgt with SMTP id\n\tfilterdrecv-p3las1-cb48d7cc9-6ppgt-19-5EBC2E96-4\n\t2020-05-13 17:29:58.430798336 +0000 UTC m=+4206148.422515078","from mail.uajain.com (unknown)\n\tby ismtpd0008p1hnd1.sendgrid.net (SG) with ESMTP\n\tid UXtBw0nfQP-LDfU0mKMn6Q Wed, 13 May 2020 17:29:58.090 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=uajain.com\n\theader.i=@uajain.com header.b=\"rnhcsiEQ\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com;\n\th=from:subject:in-reply-to:references:mime-version:to:cc:\n\tcontent-transfer-encoding:content-type;\n\ts=s1; bh=LDtxLbPplyDb22escqBemAmJKdBkt2XuDkj3m6ZFUBo=;\n\tb=rnhcsiEQMopSTbOtzxp3UmbJk8Tk6UIbnLKcMP8n0PUffrgeNad9NAwFnV7ajOZt6ZN+\n\tnbGiVckSRtD9e7/nmenFM0QysIUPCX1lKr0kU19a3TYEK0XzyNf+s2lgdlWt41g9EjLfEI\n\tOnz1eWhYBN9H4POZEZKrr1Fzr9CjNZ1nA=","From":"Umang Jain <email@uajain.com>","Date":"Wed, 13 May 2020 17:29:58 +0000 (UTC)","Message-Id":"<20200513172950.72685-3-email@uajain.com>","In-Reply-To":"<20200513172950.72685-1-email@uajain.com>","References":"<20200513172950.72685-1-email@uajain.com>","Mime-Version":"1.0","X-SG-EID":"1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPclq38gSC/txiORZpK15NbTl7AhXvTDHCpy7PI7ewHqvpLN7lOwsSlZiy3BEDPP24epCBIsoYRSB9MsJoEnNgU1Ul4l1VtzvVcxrTgNs24778WyNEYrT6MZZ60YfTbHtMkxiMuF875F10o2ZOfn8woDj6WhB4DZj4z6J20gkBFtXZe8EEr2EHWf0eWpnM4TUXZ9F5j+XtJq7r5ToXH2RY/TQ==","To":"libcamera-devel <libcamera-devel@lists.libcamera.org>","Content-Transfer-Encoding":"7bit","Content-Type":"text/plain; charset=us-ascii","Subject":"[libcamera-devel] [PATCH v2 2/5] libcamera: device_enumerator: Emit\n\ta signal when a new device is hotplugged","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":"Wed, 13 May 2020 17:30:01 -0000"},"content":"Emit a signal whenever is a new MediaDevice is added to the\nDeviceEnumerator. This will allow CameraManager to get notified\nabout the new devices that have been hot-plugged.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n src/libcamera/camera_manager.cpp          |  4 ++--\n src/libcamera/device_enumerator.cpp       | 12 ++++++++++++\n src/libcamera/include/device_enumerator.h |  4 ++++\n 3 files changed, 18 insertions(+), 2 deletions(-)","diff":"diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 1579ad4..a13cfe1 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -154,12 +154,12 @@ void CameraManager::Private::enumerateDevices()\n \t\t}\n \t}\n \n-\t/* \\todo register hot-plug callback here */\n+\tenumerator_->newDevicesFound.connect(this, &Private::enumerateDevices);\n }\n \n void CameraManager::Private::cleanup()\n {\n-\t/* \\todo unregister hot-plug callback here */\n+\tenumerator_->newDevicesFound.disconnect(this, &Private::enumerateDevices);\n \n \t/*\n \t * Release all references to cameras and pipeline handlers to ensure\ndiff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex dd17e3e..0492a86 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -227,6 +227,15 @@ std::unique_ptr<MediaDevice> DeviceEnumerator::createDevice(const std::string &d\n \treturn media;\n }\n \n+/**\n+* \\brief Notify of new media devices being found\n+*\n+* This signal is emitted when the device enumerator finds new media devices in\n+* the system. It may be emitted for every newly detected device, or once for\n+* multiple of devices, at the discretion of the device enumerator. Not all\n+* device enumerator types may support dynamic detection of new devices.\n+*/\n+\n /**\n  * \\brief Add a media device to the enumerator\n  * \\param[in] media media device instance to add\n@@ -242,6 +251,9 @@ void DeviceEnumerator::addDevice(std::unique_ptr<MediaDevice> &&media)\n \t\t<< \"Added device \" << media->deviceNode() << \": \" << media->driver();\n \n \tdevices_.push_back(std::move(media));\n+\n+\t/* \\todo: To batch multiple additions, emit with a small delay here. */\n+\tnewDevicesFound.emit();\n }\n \n /**\ndiff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\nindex 433e357..cd4e846 100644\n--- a/src/libcamera/include/device_enumerator.h\n+++ b/src/libcamera/include/device_enumerator.h\n@@ -13,6 +13,8 @@\n \n #include <linux/media.h>\n \n+#include <libcamera/signal.h>\n+\n namespace libcamera {\n \n class MediaDevice;\n@@ -43,6 +45,8 @@ public:\n \n \tstd::shared_ptr<MediaDevice> search(const DeviceMatch &dm);\n \n+\tSignal<> newDevicesFound;\n+\n protected:\n \tstd::unique_ptr<MediaDevice> createDevice(const std::string &deviceNode);\n \tvoid addDevice(std::unique_ptr<MediaDevice> &&media);\n","prefixes":["libcamera-devel","v2","2/5"]}