Show a patch.

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

{
    "id": 100,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/100/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/100/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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-7-niklas.soderlund@ragnatech.se>",
    "date": "2018-12-29T03:28:49",
    "name": "[libcamera-devel,v2,06/12] libcamera: device_enumerator: add DeviceEnumeratorUdev class",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "7e738c7647c9ef965230b8a610557bc882b20498",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/100/mbox/",
    "series": [
        {
            "id": 41,
            "url": "https://patchwork.libcamera.org/api/1.1/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/100/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/100/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 8B19860B33\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Dec 2018 04:29:55 +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 fb5a72bb-0b19-11e9-911a-0050569116f7;\n\tSat, 29 Dec 2018 04:29:43 +0100 (CET)"
        ],
        "X-Halon-ID": "fb5a72bb-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:49 +0100",
        "Message-Id": "<20181229032855.26249-7-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 06/12] libcamera: device_enumerator:\n\tadd DeviceEnumeratorUdev 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:56 -0000"
    },
    "content": "Provide a DeviceEnumeratorUdev class which is a specialization\nof DeviceEnumerator which uses udev to enumerate information in the\nsystem.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n* Changes since v1\n- s/NULL/nullptr/\n- s/foo == NULL/!foo/\n- Break log messages to not exceed 80 chars.\n- Return a std::string from lookupDevnode().\n---\n src/libcamera/device_enumerator.cpp       | 98 +++++++++++++++++++++++\n src/libcamera/include/device_enumerator.h | 15 ++++\n 2 files changed, 113 insertions(+)",
    "diff": "diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex df9e89a1afeecda1..3cafd0d3703dac99 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -266,4 +266,102 @@ DeviceInfo *DeviceEnumerator::search(DeviceMatch &dm) const\n \treturn info;\n }\n \n+/* -----------------------------------------------------------------------------\n+ * Enumerator Udev\n+ */\n+\n+DeviceEnumeratorUdev::DeviceEnumeratorUdev()\n+\t: udev_(nullptr)\n+{\n+}\n+\n+DeviceEnumeratorUdev::~DeviceEnumeratorUdev()\n+{\n+\tif (udev_)\n+\t\tudev_unref(udev_);\n+}\n+\n+int DeviceEnumeratorUdev::init()\n+{\n+\tif (udev_)\n+\t\treturn -EBUSY;\n+\n+\tudev_ = udev_new();\n+\tif (!udev_)\n+\t\treturn -ENODEV;\n+\n+\treturn 0;\n+}\n+\n+int DeviceEnumeratorUdev::enumerate()\n+{\n+\tstruct udev_enumerate *udev_enum = nullptr;\n+\tstruct udev_list_entry *ents, *ent;\n+\tint ret;\n+\n+\tudev_enum = udev_enumerate_new(udev_);\n+\tif (!udev_enum)\n+\t\treturn -ENOMEM;\n+\n+\tret = udev_enumerate_add_match_subsystem(udev_enum, \"media\");\n+\tif (ret < 0)\n+\t\tgoto done;\n+\n+\tret = udev_enumerate_scan_devices(udev_enum);\n+\tif (ret < 0)\n+\t\tgoto done;\n+\n+\tents = udev_enumerate_get_list_entry(udev_enum);\n+\tif (!ents)\n+\t\tgoto done;\n+\n+\tudev_list_entry_foreach(ent, ents) {\n+\t\tstruct udev_device *dev;\n+\t\tconst char *devnode;\n+\t\tconst char *syspath = udev_list_entry_get_name(ent);\n+\n+\t\tdev = udev_device_new_from_syspath(udev_, syspath);\n+\t\tif (!dev) {\n+\t\t\tLOG(Error) << \"Failed to get device for '\" <<\n+\t\t\t\t   syspath << \"', skipping\";\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tdevnode = udev_device_get_devnode(dev);\n+\t\tif (!devnode) {\n+\t\t\tudev_device_unref(dev);\n+\t\t\tret = -ENODEV;\n+\t\t\tgoto done;\n+\t\t}\n+\n+\t\taddDevice(devnode);\n+\n+\t\tudev_device_unref(dev);\n+\t}\n+done:\n+\tudev_enumerate_unref(udev_enum);\n+\treturn ret >= 0 ? 0 : ret;\n+}\n+\n+std::string DeviceEnumeratorUdev::lookupDevnode(int major, int minor)\n+{\n+\tstruct udev_device *device;\n+\tconst char *name;\n+\tdev_t devnum;\n+\tstd::string devnode(\"\");\n+\n+\tdevnum = makedev(major, minor);\n+\tdevice = udev_device_new_from_devnum(udev_, 'c', devnum);\n+\tif (!device)\n+\t\treturn \"\";\n+\n+\tname = udev_device_get_devnode(device);\n+\tif (name)\n+\t\tdevnode = name;\n+\n+\tudev_device_unref(device);\n+\n+\treturn devnode;\n+}\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h\nindex 1f8cef3311012308..5348e6cf583dbd15 100644\n--- a/src/libcamera/include/device_enumerator.h\n+++ b/src/libcamera/include/device_enumerator.h\n@@ -75,6 +75,21 @@ private:\n \tvirtual std::string lookupDevnode(int major, int minor) = 0;\n };\n \n+class DeviceEnumeratorUdev: public DeviceEnumerator\n+{\n+public:\n+\tDeviceEnumeratorUdev();\n+\t~DeviceEnumeratorUdev();\n+\n+\tint init() final;\n+\tint enumerate() final;\n+\n+private:\n+\tstruct udev *udev_;\n+\n+\tstd::string lookupDevnode(int major, int minor) final;\n+};\n+\n } /* namespace libcamera */\n \n #endif\t/* __LIBCAMERA_DEVICE_ENUMERATOR_H__ */\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "06/12"
    ]
}