Show a patch.

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

{
    "id": 14958,
    "url": "https://patchwork.libcamera.org/api/patches/14958/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14958/",
    "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": "<20211201115711.1017822-3-naush@raspberrypi.com>",
    "date": "2021-12-01T11:57:11",
    "name": "[libcamera-devel,v1,2/2] pipeline: raspberrypi: Add support for Video Mux and Bridge devices",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b782de445ae943a8055bad1b24583c04049d3a13",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14958/mbox/",
    "series": [
        {
            "id": 2793,
            "url": "https://patchwork.libcamera.org/api/series/2793/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2793",
            "date": "2021-12-01T11:57:09",
            "name": "Raspberry Pi: Add video mux and bridge support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2793/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14958/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14958/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 3ECD4BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Dec 2021 11:57:26 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E1A516072B;\n\tWed,  1 Dec 2021 12:57:25 +0100 (CET)",
            "from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n\t[IPv6:2a00:1450:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D0FD460729\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 12:57:23 +0100 (CET)",
            "by mail-wr1-x430.google.com with SMTP id u1so51619362wru.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 01 Dec 2021 03:57:23 -0800 (PST)",
            "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:9907:13eb:bd49:5862])\n\tby smtp.gmail.com with ESMTPSA id\n\tf13sm1139451wmq.29.2021.12.01.03.57.22\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 01 Dec 2021 03:57:22 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"h7UfYQCn\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=XVI1aAlrGYw5+gRkS8jX1UKJLOe2buBKYIv9RhJ0V4I=;\n\tb=h7UfYQCnegSZM7gPvFg8mMw9aFhEjJOsj9p1kVOHmkrbDiGnMzw/2HskWHZwyGl14I\n\td0VeQp/4A4VYmDv7lCjGqZEEP604+FjPkVE+T7DezEwk5+CjoMp4oSra2C6jvJBPiE9T\n\tp+bThoTdBs0TItTbZtQr3sITMvYK13L5+ZrGId2EQnzV7JaiR395hsBNRXMyM0tEpTmP\n\tDKAhOEoZ/WkmX8oXspI8wViflFslgw08+9yu01Nx1UQs39UvjPRCdGW3PSHGGQp/PBys\n\tPmu4SfNKuYZvAoLquCTF1rTEvVBk5K+yBWUYQbhiaS2eet7ne+8MySzqaB0ouumJ4FtT\n\tQ2NA==",
        "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=XVI1aAlrGYw5+gRkS8jX1UKJLOe2buBKYIv9RhJ0V4I=;\n\tb=it4v4BLGnOMynNpxc3gscJj/jv97d0cL9G/lnDBYfvCFuzFObn5GVWqQkSTrq+sKzb\n\txa58yaH0vtf5YTNF8W/8HP/5A8n/3JcmnmCKkAZCm3pIOvbUsQjECKaWUscTKyZhBDua\n\tODRKg9dHHEKRXmwXXshSAqO8fCvZ79Ux1EvtaGHtpi/C0M0J4YKJEJeb1qHttTSprCp6\n\tyeFM2JlsYyBp/k+oBQ1tpBvLtpZIE/qPCd7jVn7n7H9AxxzKiBSz22JMnNdCjspDXyn2\n\tQAxf0gmpN/tATnpK2NP9SvmshuaSYNTLVmoDaJ0VYrmNvw3KJPHK/O3zTLaLuxqv0eOb\n\tRshg==",
        "X-Gm-Message-State": "AOAM533E37XlOLSTqP9TK8jPrf8Pqf1jRdX6KHGWz4iAbNTeNMoGYLgJ\n\tTlHnXVwHeebxghLU+ra5DoYUBkEf7a1/nEwj",
        "X-Google-Smtp-Source": "ABdhPJx2NZipyKwJlesWgfqkRKzW7FTmUQ9sJZUxV+CRCIP40tj8pMrYu51bWbzSLYX4Yf20V+cmTw==",
        "X-Received": "by 2002:adf:a404:: with SMTP id d4mr6261264wra.556.1638359843312;\n\tWed, 01 Dec 2021 03:57:23 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  1 Dec 2021 11:57:11 +0000",
        "Message-Id": "<20211201115711.1017822-3-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20211201115711.1017822-1-naush@raspberrypi.com>",
        "References": "<20211201115711.1017822-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v1 2/2] pipeline: raspberrypi: Add support\n\tfor Video Mux and Bridge devices",
        "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": "This change will allow the pipeline handler to enumerate and control Video\nMux or Bridge devices that may be attached between sensors and a particular\nUnicam instance. Cascaded mux or bridge devices are also handled.\n\nA new member function enumerateVideoDevices(), called from registerCamera(), is\nused to identify and open all mux and bridge subdevices present in the\nsensor -> Unicam link.\n\nRelevent links are enabled/disabled and pad formats correctly set in configure()\nbefore the camera is started.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 60 +++++++++++++++++++\n 1 file changed, 60 insertions(+)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 811160490f5c..2512d0746d4a 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -11,6 +11,7 @@\n #include <mutex>\n #include <queue>\n #include <unordered_set>\n+#include <utility>\n \n #include <libcamera/camera.h>\n #include <libcamera/control_ids.h>\n@@ -224,6 +225,11 @@ public:\n \tstd::vector<RPi::Stream *> streams_;\n \t/* Stores the ids of the buffers mapped in the IPA. */\n \tstd::unordered_set<unsigned int> ipaBuffers_;\n+\t/*\n+\t * Stores a cascade of Video Mux or Bridge devices between the sensor and\n+\t * Unicam together with the sink pad of the entity.\n+\t */\n+\tstd::vector<std::pair<std::unique_ptr<V4L2Subdevice>, const MediaPad *>> videoDevices;\n \n \t/* DMAHEAP allocation helper. */\n \tRPi::DmaHeap dmaHeap_;\n@@ -315,6 +321,7 @@ private:\n \t}\n \n \tint registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity);\n+\tvoid enumerateVideoDevices(RPiCameraData *data, const MediaPad *sinkPad);\n \tint queueAllBuffers(Camera *camera);\n \tint prepareBuffers(Camera *camera);\n \tvoid freeBuffers(Camera *camera);\n@@ -848,6 +855,24 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t */\n \tdata->properties_.set(properties::ScalerCropMaximum, data->sensorInfo_.analogCrop);\n \n+\t/* Setup the Video Mux/Bridge entities. */\n+\tfor (auto &[device, pad] : data->videoDevices) {\n+\t\t/* Start by disabling all the sink pad links on the devices in the cascade. */\n+\t\tfor (const MediaPad *p : device->entity()->pads()) {\n+\t\t\tif (!(p->flags() & MEDIA_PAD_FL_SINK))\n+\t\t\t\tcontinue;\n+\n+\t\t\tfor (MediaLink *l : p->links())\n+\t\t\t\tl->setEnabled(false);\n+\t\t}\n+\n+\t\t/* Finally enable the link to this camera, and setup the pad format. */\n+\t\tdata->sensor_->entity()->pads()[0]->links()[0]->setEnabled(true);\n+\t\tret = device->setFormat(pad->index(), &sensorFormat);\n+\t\tLOG(RPI, Info) << \"Configured media link on device \" << device->entity()->name()\n+\t\t\t       << \" at pad \" << pad->index();\n+\t}\n+\n \treturn ret;\n }\n \n@@ -1078,6 +1103,13 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me\n \tif (data->sensor_->init())\n \t\treturn -EINVAL;\n \n+\t/*\n+\t * Enumerate all the Video Mux/Bridge devices across the sensor -> unicam\n+\t * link. There may be a cascade of devices in this link!\n+\t */\n+\tMediaPad *sensorSinkPad = sensorEntity->getPadByIndex(0)->links()[0]->sink();\n+\tenumerateVideoDevices(data.get(), sensorSinkPad);\n+\n \tdata->sensorFormats_ = populateSensorFormats(data->sensor_);\n \n \tipa::RPi::SensorConfig sensorConfig;\n@@ -1204,6 +1236,34 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me\n \treturn 0;\n }\n \n+void PipelineHandlerRPi::enumerateVideoDevices(RPiCameraData *data, const MediaPad *sinkPad)\n+{\n+\tconst MediaEntity *entity = sinkPad->entity();\n+\n+\t/* We only deal with Video Mux and Bridge devices in cascade. */\n+\tif (entity->function() != MEDIA_ENT_F_VID_MUX &&\n+\t    entity->function() != MEDIA_ENT_F_VID_IF_BRIDGE)\n+\t\treturn;\n+\n+\tLOG(RPI, Info) << \"Found video mux device \" << entity->name()\n+\t\t       << \" linked to sink pad \" << sinkPad->index();\n+\n+\tdata->videoDevices.emplace_back(std::make_unique<V4L2Subdevice>(entity), sinkPad);\n+\tdata->videoDevices.back().first->open();\n+\n+\tfor (const MediaPad *pad : entity->pads()) {\n+\t\t/*\n+\t\t * Iterate through all the sink pads down the cascade to find any\n+\t\t * other Video Mux and Bridge devices.\n+\t\t */\n+\t\tif (!(pad->flags() & MEDIA_PAD_FL_SOURCE))\n+\t\t\tcontinue;\n+\n+\t\tfor (const MediaLink *l : pad->links())\n+\t\t\tenumerateVideoDevices(data, l->sink());\n+\t}\n+}\n+\n int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n {\n \tRPiCameraData *data = cameraData(camera);\n",
    "prefixes": [
        "libcamera-devel",
        "v1",
        "2/2"
    ]
}