Show a patch.

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

{
    "id": 3834,
    "url": "https://patchwork.libcamera.org/api/patches/3834/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3834/",
    "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": "<20200521135416.13685-3-email@uajain.com>",
    "date": "2020-05-21T13:54:25",
    "name": "[libcamera-devel,v3,2/5] libcamera: device_enumerator: Emit a signal when a new devices are added",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "2818783b5671b32c6156ce12c7e0c403abcc9fdc",
    "submitter": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/people/1/?format=api",
        "name": "Umang Jain",
        "email": "email@uajain.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3834/mbox/",
    "series": [
        {
            "id": 920,
            "url": "https://patchwork.libcamera.org/api/series/920/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=920",
            "date": "2020-05-21T13:54:23",
            "name": "Introduce UVC hotplugging support",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/920/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3834/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3834/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 0BC5E60E3A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 May 2020 15:54:26 +0200 (CEST)",
            "by filterdrecv-p3iad2-8ddf98858-xxtk7 with SMTP id\n\tfilterdrecv-p3iad2-8ddf98858-xxtk7-19-5EC68811-F\n\t2020-05-21 13:54:25.454086813 +0000 UTC m=+4884415.326188984",
            "from mail.uajain.com (unknown)\n\tby ismtpd0002p1maa1.sendgrid.net (SG) with ESMTP id\n\tAPaP3d8zSB6JcgguhOnXrA for <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 May 2020 13:54:24.468 +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=\"RHmLBNsm\"; \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=947S7DVuvlTm+8i8IFP//rdO5Jthn/wz8+oYu/zUtq0=;\n\tb=RHmLBNsmekG7tTDKP40BgpvXkLDACRuTqsBoQ5t1PgFehYwbeQPTz2i91N/k5LRoMEWG\n\tuZMKU0TbisVHFZbsSWtV7PFAIRYjLEu/FoRgHyUrVhTdWmXvtoBs8WWkSwbOTdsyHq9OKJ\n\tpDvj53Y8Kal0Ud2CbcZIx6SQXffyEfQZg=",
        "From": "Umang Jain <email@uajain.com>",
        "Date": "Thu, 21 May 2020 13:54:25 +0000 (UTC)",
        "Message-Id": "<20200521135416.13685-3-email@uajain.com>",
        "In-Reply-To": "<20200521135416.13685-1-email@uajain.com>",
        "References": "<20200521135416.13685-1-email@uajain.com>",
        "Mime-Version": "1.0",
        "X-SG-EID": "1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcREc2X1LpIgLW8oEasGbeg2Bl5j4DWfGLn/larXYgYhgN9fr5OnjLUzMofQ4XGnoUUbc9ciKFxnN1DhxKKazKGtf/TmgJnZzfgVlMD1QhZE3850RZLqVqnxHn5SF1+1v6wCGacd8oB+r12bRC+Tnrw3xe3L6Yw7O3mmLaKPBaDZkI9bcrA18JwMyWjACttepfoHkBFS2Me2QVY0yyzky03Q==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Content-Transfer-Encoding": "7bit",
        "Content-Type": "text/plain; charset=us-ascii",
        "Subject": "[libcamera-devel] [PATCH v3 2/5] libcamera: device_enumerator: Emit\n\ta signal when a new devices are added",
        "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": "Thu, 21 May 2020 13:54:27 -0000"
    },
    "content": "Emit a signal whenever a new MediaDevice(s) are added to the\nDeviceEnumerator. This will allow CameraManager to be notified\nabout the new devices and it can re-emumerate all the devices\ncurrently present on the system.\n\nDevice enumeration by the CameraManger is a expensive operation hence,\nwe want one signal emission per 'x' milliseconds to notify multiple\ndevices additions as a single batch, by the DeviceEnumerator.\nAdd a \\todo to investigate the support for that.\n\nSigned-off-by: Umang Jain <email@uajain.com>\n---\n include/libcamera/internal/device_enumerator.h |  4 ++++\n src/libcamera/camera_manager.cpp               |  4 ++--\n src/libcamera/device_enumerator.cpp            | 13 +++++++++++++\n 3 files changed, 19 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h\nindex 433e357..aa6a6fe 100644\n--- a/include/libcamera/internal/device_enumerator.h\n+++ b/include/libcamera/internal/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<> deviceAdded;\n+\n protected:\n \tstd::unique_ptr<MediaDevice> createDevice(const std::string &deviceNode);\n \tvoid addDevice(std::unique_ptr<MediaDevice> &&media);\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 8d9cb02..27064d2 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -153,12 +153,12 @@ void CameraManager::Private::enumerateDevices()\n \t\t}\n \t}\n \n-\t/* \\todo register hot-plug callback here */\n+\tenumerator_->deviceAdded.connect(this, &Private::enumerateDevices);\n }\n \n void CameraManager::Private::cleanup()\n {\n-\t/* \\todo unregister hot-plug callback here */\n+\tenumerator_->deviceAdded.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 e21a2a7..6c5ebb7 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -227,6 +227,16 @@ std::unique_ptr<MediaDevice> DeviceEnumerator::createDevice(const std::string &d\n \treturn media;\n }\n \n+/**\n+* \\var DeviceEnumerator::deviceAdded\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 +252,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+\tdeviceAdded.emit();\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "2/5"
    ]
}