Show a patch.

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

{
    "id": 544,
    "url": "https://patchwork.libcamera.org/api/patches/544/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/544/",
    "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": "<20190207212119.30299-2-kieran.bingham@ideasonboard.com>",
    "date": "2019-02-07T21:21:15",
    "name": "[libcamera-devel,1/5] libcamera: media_device: Provide the default entity",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8af430aa8512320107d1039ad82aed200520fc70",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/544/mbox/",
    "series": [
        {
            "id": 171,
            "url": "https://patchwork.libcamera.org/api/series/171/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=171",
            "date": "2019-02-07T21:21:14",
            "name": "libcamera: Buffer Sharing",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/171/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/544/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/544/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5667A610B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Feb 2019 22:21:28 +0100 (CET)",
            "from localhost.localdomain (unknown [149.254.234.206])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 76F62567;\n\tThu,  7 Feb 2019 22:21:27 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549574488;\n\tbh=Kx2RrxQC4y3ZhPm8fExrDxplTK4s45n0LOOgSqbgMjs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=EobfsUHaIdl9dJMxpN9p+buXQBqrw9N7K3M/xv7+H7s1Ffnqt6k5ebOCZvWIE3WTs\n\tPJLP5+jM/s7KQvlR2FWXuqjSZmTQ4lGLECRYoBOAhYVz9eAY/lEPV1dIwVz16+1Ve0\n\tBwGj2wDd/boUjWha/Y1EztuYp2+uN7HgheAs7zgg=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Thu,  7 Feb 2019 21:21:15 +0000",
        "Message-Id": "<20190207212119.30299-2-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.19.1",
        "In-Reply-To": "<20190207212119.30299-1-kieran.bingham@ideasonboard.com>",
        "References": "<20190207212119.30299-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/5] libcamera: media_device: Provide the\n\tdefault entity",
        "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": "Thu, 07 Feb 2019 21:21:28 -0000"
    },
    "content": "Add a helper to identify the default entity from a media device.\n\nUtilise it in the two places which iterate the entities manually, to allocated\na V4L2Device from the default entity.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/include/media_device.h  |  1 +\n src/libcamera/media_device.cpp        | 15 +++++++++++++++\n src/libcamera/pipeline/uvcvideo.cpp   | 10 ++++------\n test/v4l2_device/v4l2_device_test.cpp | 12 +++++-------\n 4 files changed, 25 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h\nindex 9f038093b2b2..361e8f4a4b86 100644\n--- a/src/libcamera/include/media_device.h\n+++ b/src/libcamera/include/media_device.h\n@@ -42,6 +42,7 @@ public:\n \n \tconst std::vector<MediaEntity *> &entities() const { return entities_; }\n \tMediaEntity *getEntityByName(const std::string &name) const;\n+\tMediaEntity *defaultEntity() const;\n \n \tMediaLink *link(const std::string &sourceName, unsigned int sourceIdx,\n \t\t\tconst std::string &sinkName, unsigned int sinkIdx);\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 800ed330fe6d..4af90e1590a1 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -319,6 +319,21 @@ MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n \treturn nullptr;\n }\n \n+/**\n+ * \\brief Return the default MediaEntity within a MediaDevice\n+ * \\return The default entity if specified, or a nullptr otherwise\n+ */\n+MediaEntity *MediaDevice::defaultEntity() const\n+{\n+\tfor (MediaEntity *entity : entities_) {\n+\t\tif (entity->flags() & MEDIA_ENT_FL_DEFAULT) {\n+\t\t\treturn entity;\n+\t\t}\n+\t}\n+\n+\treturn nullptr;\n+}\n+\n /**\n  * \\brief Retrieve the MediaLink connecting two pads, identified by entity\n  * names and pad indexes\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex fc31c52c0ecd..ed8228bb2fc6 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -146,13 +146,11 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \n \tmedia_->acquire();\n \n-\tfor (MediaEntity *entity : media_->entities()) {\n-\t\tif (entity->flags() & MEDIA_ENT_FL_DEFAULT) {\n-\t\t\tvideo_ = new V4L2Device(entity);\n-\t\t\tbreak;\n-\t\t}\n-\t}\n+\tMediaEntity *entity = media_->defaultEntity();\n+\tif (!entity)\n+\t\treturn false;\n \n+\tvideo_ = new V4L2Device(entity);\n \tif (!video_ || video_->open()) {\n \t\tif (!video_)\n \t\t\tLOG(UVC, Error) << \"Could not find a default video device\";\ndiff --git a/test/v4l2_device/v4l2_device_test.cpp b/test/v4l2_device/v4l2_device_test.cpp\nindex 18d014caf4c8..dd28cccada6b 100644\n--- a/test/v4l2_device/v4l2_device_test.cpp\n+++ b/test/v4l2_device/v4l2_device_test.cpp\n@@ -46,15 +46,13 @@ int V4L2DeviceTest::init()\n \n \tmedia_->acquire();\n \n-\tfor (MediaEntity *entity : media_->entities()) {\n-\t\tif (entity->flags() & MEDIA_ENT_FL_DEFAULT) {\n-\t\t\tdev_ = new V4L2Device(entity);\n-\t\t\tbreak;\n-\t\t}\n-\t}\n+\tMediaEntity *entity = media_->defaultEntity();\n+\tif (!entity)\n+\t\treturn TestFail;\n \n+\tdev_ = new V4L2Device(entity);\n \tif (!dev_)\n-\t\treturn TestSkip;\n+\t\treturn TestFail;\n \n \treturn dev_->open();\n }\n",
    "prefixes": [
        "libcamera-devel",
        "1/5"
    ]
}