Show a patch.

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

{
    "id": 15032,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/15032/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15032/",
    "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": "<20211203224230.38700-3-djrscally@gmail.com>",
    "date": "2021-12-03T22:42:25",
    "name": "[libcamera-devel,v2,2/7] libcamera: media_device: Handle ancillary links in populateLinks()",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "6305251711e678ba8116079ef55c6af6d3e4acf8",
    "submitter": {
        "id": 90,
        "url": "https://patchwork.libcamera.org/api/1.1/people/90/?format=api",
        "name": "Daniel Scally",
        "email": "djrscally@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15032/mbox/",
    "series": [
        {
            "id": 2815,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2815/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2815",
            "date": "2021-12-03T22:42:23",
            "name": "Enumerate CameraLens by following sensor's ancillary links",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2815/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15032/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15032/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 32EB6BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Dec 2021 22:42:41 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E8FB06086C;\n\tFri,  3 Dec 2021 23:42:40 +0100 (CET)",
            "from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n\t[IPv6:2a00:1450:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D7F8607DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Dec 2021 23:42:38 +0100 (CET)",
            "by mail-wr1-x429.google.com with SMTP id d24so8825999wra.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Dec 2021 14:42:38 -0800 (PST)",
            "from localhost.localdomain\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161])\n\tby smtp.gmail.com with ESMTPSA id\n\to25sm3939919wms.17.2021.12.03.14.42.37\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Dec 2021 14:42:37 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Tb9x/VUQ\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=wP5Mk610fVyffoaymXg9kkRA0t99CmQnxwVpbCNOf7Y=;\n\tb=Tb9x/VUQBtlaNVLKp5EJLibqmDco3vTZeYCyS4mE6YEcX6+BXbahLzAw1RnV7E96DD\n\tgpJGLQbyn/kGE8itT+R7D1B2qB9PgudoObhmv4X7LeChpr5IRG5xqU/JKc8UwJtA/36W\n\tYHdH2EXbPPnPoadV1IxY44fW4s0nxI8kq9KUj7d6giDftnaK9voK4ClUCk3jcAdQ7L2W\n\tYCrUzPrNkSA7p4NLDeNYV8TCn03CTBsmXxMJNpaUjm9CsnMk6Ix3Ren1uYEkX/6NF4QU\n\t3QOgtrlqC6fxQpE2/N3bzdKimbx4PUllrQv9HEg3hwjcZhPLNT3Te4iw7XbBX3iIg5TF\n\tVRjg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=wP5Mk610fVyffoaymXg9kkRA0t99CmQnxwVpbCNOf7Y=;\n\tb=jHXz3Zey1xX/IUqHq6+N4N6OHJ090kZoXa8C5bnYe1CvVJ9MBfE3AiaAqfIixoIQTr\n\tlI5gYhOF3eK9iGavteL49+1Xy79KN7cGsuNKp2l4/b58tgSR/yHpUI+popnkOHay5DCv\n\tGUxb7/oWb6FrAWiEAMMP1iAUvewt7uQ1E0PKOG1u7AFnj7+ebwB4QBtdNsF6dZpqVI5A\n\tpi5zaxnPMwkVBg0/Wql7jYcDXoNE6kseHSTTP0JORLu5iKTjuAWa8KsMWAAYpRrfaEpM\n\tXDTtSFHG63nAg4TaBQEyuo9Ces7pbQCM/q7jwmiAQC+Ga5UgzOvFddpZPQypfotbeHhW\n\topMw==",
        "X-Gm-Message-State": "AOAM531kh42as7ZXScRaVKuD7HE4bj2zolMQxa1AkolF0zf4CcxANy/v\n\tRhGixINpdaHh0eKQwmb5i1N98DCUXDQ=",
        "X-Google-Smtp-Source": "ABdhPJx6ndwDfg6t88v4bUhLdjH8MtofNAIN2rdWuT5sXOHGC/rfY/aaUgdARio4tbFD2vcTa+TV6Q==",
        "X-Received": "by 2002:a5d:522e:: with SMTP id\n\ti14mr24166634wra.43.1638571358133; \n\tFri, 03 Dec 2021 14:42:38 -0800 (PST)",
        "From": "Daniel Scally <djrscally@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  3 Dec 2021 22:42:25 +0000",
        "Message-Id": "<20211203224230.38700-3-djrscally@gmail.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20211203224230.38700-1-djrscally@gmail.com>",
        "References": "<20211203224230.38700-1-djrscally@gmail.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 2/7] libcamera: media_device: Handle\n\tancillary links in populateLinks()",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The populateLinks() function can't currently handle ancillary links\nwhich causes an error to be thrown in process() when the MediaObject\ncannot be cast to a MediaPad.\n\nAdd explicit handling for the different link types, creating either\npad-2-pad links or else storing the pointer to the ancillary device\nMediaEntity in the ancillaryEntities_ member of the primary.\n\nSigned-off-by: Daniel Scally <djrscally@gmail.com>\n---\nChanges in v2:\n\n\t- Storing pointer to the sink entity in the new ancillaryEntities_\n\tvector of the source entity where in case MEDIA_LNK_FL_ANCILLARY_LINK\n\trather than creating a MediaLink (Laurent)\n\n include/linux/media.h          |  1 +\n src/libcamera/media_device.cpp | 46 +++++++++++++++++++++++-----------\n 2 files changed, 32 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/include/linux/media.h b/include/linux/media.h\nindex 17432318..e3123d1a 100644\n--- a/include/linux/media.h\n+++ b/include/linux/media.h\n@@ -222,6 +222,7 @@ struct media_pad_desc {\n #define MEDIA_LNK_FL_LINK_TYPE\t\t\t(0xf << 28)\n #  define MEDIA_LNK_FL_DATA_LINK\t\t(0 << 28)\n #  define MEDIA_LNK_FL_INTERFACE_LINK\t\t(1 << 28)\n+#  define MEDIA_LNK_FL_ANCILLARY_LINK\t\t(2 << 28)\n \n struct media_link_desc {\n \tstruct media_pad_desc source;\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex aa93da75..6eddb5a0 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -699,45 +699,61 @@ bool MediaDevice::populateLinks(const struct media_v2_topology &topology)\n {\n \tstruct media_v2_link *mediaLinks = reinterpret_cast<struct media_v2_link *>\n \t\t\t\t\t   (topology.ptr_links);\n+\tunsigned int link_type;\n+\tMediaLink *link;\n \n \tfor (unsigned int i = 0; i < topology.num_links; ++i) {\n \t\t/*\n \t\t * Skip links between entities and interfaces: we only care\n-\t\t * about pad-2-pad links here.\n+\t\t * about pad-2-pad and entity-2-entity links here.\n \t\t */\n \t\tif ((mediaLinks[i].flags & MEDIA_LNK_FL_LINK_TYPE) ==\n \t\t    MEDIA_LNK_FL_INTERFACE_LINK)\n \t\t\tcontinue;\n \n-\t\t/* Store references to source and sink pads in the link. */\n+\t\t/* Store references to source and sink objects in the link. */\n \t\tunsigned int source_id = mediaLinks[i].source_id;\n-\t\tMediaPad *source = dynamic_cast<MediaPad *>\n-\t\t\t\t   (object(source_id));\n+\t\tMediaObject *source = object(source_id);\n \t\tif (!source) {\n \t\t\tLOG(MediaDevice, Error)\n-\t\t\t\t<< \"Failed to find pad with id: \"\n+\t\t\t\t<< \"Failed to find MediaObject with id: \"\n \t\t\t\t<< source_id;\n \t\t\treturn false;\n \t\t}\n \n \t\tunsigned int sink_id = mediaLinks[i].sink_id;\n-\t\tMediaPad *sink = dynamic_cast<MediaPad *>\n-\t\t\t\t (object(sink_id));\n+\t\tMediaObject *sink = object(sink_id);\n \t\tif (!sink) {\n \t\t\tLOG(MediaDevice, Error)\n-\t\t\t\t<< \"Failed to find pad with id: \"\n+\t\t\t\t<< \"Failed to find MediaObject with id: \"\n \t\t\t\t<< sink_id;\n \t\t\treturn false;\n \t\t}\n \n-\t\tMediaLink *link = new MediaLink(&mediaLinks[i], source, sink);\n-\t\tif (!addObject(link)) {\n-\t\t\tdelete link;\n-\t\t\treturn false;\n-\t\t}\n+\t\tlink_type = mediaLinks[i].flags & MEDIA_LNK_FL_LINK_TYPE;\n+\n+\t\tswitch (link_type) {\n+\t\tcase MEDIA_LNK_FL_DATA_LINK:\n+\t\t\tlink = new MediaLink(&mediaLinks[i],\n+\t\t\t\t\t     dynamic_cast<MediaPad *>(source),\n+\t\t\t\t\t     dynamic_cast<MediaPad *>(sink));\n+\t\t\tif (!addObject(link)) {\n+\t\t\t\tdelete link;\n+\t\t\t\treturn false;\n+\t\t\t}\n+\n+\t\t\tlink->source()->addLink(link);\n+\t\t\tlink->sink()->addLink(link);\n \n-\t\tsource->addLink(link);\n-\t\tsink->addLink(link);\n+\t\t\tbreak;\n+\t\tcase MEDIA_LNK_FL_ANCILLARY_LINK:\n+\t\t\tMediaEntity *primary = dynamic_cast<MediaEntity *>(source);\n+\t\t\tMediaEntity *ancillary = dynamic_cast<MediaEntity *>(sink);\n+\n+\t\t\tprimary->addAncillaryEntity(ancillary);\n+\n+\t\t\tbreak;\n+\t\t}\n \t}\n \n \treturn true;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/7"
    ]
}