Show a patch.

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

{
    "id": 11476,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/11476/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11476/",
    "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": "<20210303145609.20565-1-laurent.pinchart@ideasonboard.com>",
    "date": "2021-03-03T14:56:09",
    "name": "[libcamera-devel,v3] libcamera: pipeline: simple: Support camera sensors that contain an ISP",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6ea67e575a2051bed9f49b660aa640b475b1aabe",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11476/mbox/",
    "series": [
        {
            "id": 1751,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1751/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1751",
            "date": "2021-03-03T14:56:09",
            "name": "[libcamera-devel,v3] libcamera: pipeline: simple: Support camera sensors that contain an ISP",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1751/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11476/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11476/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 B96FCBD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Mar 2021 14:56:43 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C8BD68A91;\n\tWed,  3 Mar 2021 15:56:43 +0100 (CET)",
            "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 00C7E68A7E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Mar 2021 15:56:41 +0100 (CET)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5F9A58CA;\n\tWed,  3 Mar 2021 15:56:41 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"wWOuaCee\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1614783401;\n\tbh=GLuncacYWwiRBEiBTtwrP7Vp7/6qO7isvNbznE0MG0g=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=wWOuaCeeIeq74Jjf/G3k4pJGFZIVfZEh8nDrQsNHXwi6hPNWKlJ5Os9D8n0jEpbqh\n\ttQJFmjobxj2leUQbTsxwGqgIcqGRlgSDmUxhqavzsH0gMW8NYpcEoLo33yMtzZ6RH6\n\t33/yyUSu+tm6tZs7kh/Bklp3TTtn0OYZDWAKrhqs=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  3 Mar 2021 16:56:09 +0200",
        "Message-Id": "<20210303145609.20565-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.28.0",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3] libcamera: pipeline: simple: Support\n\tcamera sensors that contain an ISP",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Camera sensors can include an ISP. For instance, the AP1302 external ISP\ncan be connected to up to two raw camera sensors, and the combination of\nthe sensors and ISP is considered as a (smart) camera sensor from\nlibcamera's point of view.\n\nThe CameraSensor class has limited support for this already. Extend the\nsimple pipeline handler to support such sensors, by using the media\nentity corresponding to the ISP instead of the raw camera sensor's\nentity.\n\nWe don't need to handle the case where an entity in the SoC would expose\nthe MEDIA_ENT_F_PROC_VIDEO_ISP function, as pipeline containing an ISP\nwould have a dedicated pipeline handler.\n\nThe implementation is limited as it won't support other multi-entity\ncamera sensors (such as CCS). While this would be worth supporting, we\ndon't have a test platform with a CCS-compatible sensor at this point,\nso let's not over-engineer the solution. Extending support to CCS (and\npossibly other sensor topologies) will likely involve helpers that can\nbe used by other pipeline handlers (such as generic graph walk helpers\nfor instance) and extensions to the CameraSensor class.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v2:\n\n- Simplify link handling as all links can be enabled\n\nChanges since v1:\n\n- Fix link handling\n---\n src/libcamera/pipeline/simple/simple.cpp | 77 ++++++++++++++++++++----\n 1 file changed, 64 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 7fba495cdc14..2e09d330c0e1 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -244,6 +244,8 @@ private:\n \t\t\tPipelineHandler::cameraData(camera));\n \t}\n \n+\tstd::vector<MediaEntity *> locateSensors();\n+\n \tvoid bufferReady(FrameBuffer *buffer);\n \tvoid converterInputDone(FrameBuffer *buffer);\n \tvoid converterOutputDone(FrameBuffer *buffer);\n@@ -868,6 +870,67 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request)\n  * Match and Setup\n  */\n \n+std::vector<MediaEntity *> SimplePipelineHandler::locateSensors()\n+{\n+\tstd::vector<MediaEntity *> entities;\n+\n+\t/*\n+\t * Gather all the camera sensor entities based on the function they\n+\t * expose.\n+\t */\n+\tfor (MediaEntity *entity : media_->entities()) {\n+\t\tif (entity->function() == MEDIA_ENT_F_CAM_SENSOR)\n+\t\t\tentities.push_back(entity);\n+\t}\n+\n+\tif (entities.empty())\n+\t\treturn {};\n+\n+\t/*\n+\t * Sensors can be made of multiple entities. For instance, a raw sensor\n+\t * can be connected to an ISP, and the combination of both should be\n+\t * treated as one sensor. To support this, as a crude heuristic, check\n+\t * the downstream entity from the camera sensor, and if it is an ISP,\n+\t * use it instead of the sensor.\n+\t */\n+\tstd::vector<MediaEntity *> sensors;\n+\n+\tfor (MediaEntity *entity : entities) {\n+\t\t/*\n+\t\t * Locate the downstream entity by following the first link\n+\t\t * from a source pad.\n+\t\t */\n+\t\tconst MediaLink *link = nullptr;\n+\n+\t\tfor (const MediaPad *pad : entity->pads()) {\n+\t\t\tif ((pad->flags() & MEDIA_PAD_FL_SOURCE) &&\n+\t\t\t    !pad->links().empty()) {\n+\t\t\t\tlink = pad->links()[0];\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (!link)\n+\t\t\tcontinue;\n+\n+\t\tMediaEntity *remote = link->sink()->entity();\n+\t\tif (remote->function() == MEDIA_ENT_F_PROC_VIDEO_ISP)\n+\t\t\tsensors.push_back(remote);\n+\t\telse\n+\t\t\tsensors.push_back(entity);\n+\t}\n+\n+\t/*\n+\t * Remove duplicates, in case multiple sensors are connected to the\n+\t * same ISP.\n+\t */\n+\tstd::sort(sensors.begin(), sensors.end());\n+\tauto last = std::unique(sensors.begin(), sensors.end());\n+\tsensors.erase(last, sensors.end());\n+\n+\treturn sensors;\n+}\n+\n bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n {\n \tconst SimplePipelineInfo *info = nullptr;\n@@ -891,19 +954,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \t}\n \n \t/* Locate the sensors. */\n-\tstd::vector<MediaEntity *> sensors;\n-\n-\tfor (MediaEntity *entity : media_->entities()) {\n-\t\tswitch (entity->function()) {\n-\t\tcase MEDIA_ENT_F_CAM_SENSOR:\n-\t\t\tsensors.push_back(entity);\n-\t\t\tbreak;\n-\n-\t\tdefault:\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\n+\tstd::vector<MediaEntity *> sensors = locateSensors();\n \tif (sensors.empty()) {\n \t\tLOG(SimplePipeline, Error) << \"No sensor found\";\n \t\treturn false;\n",
    "prefixes": [
        "libcamera-devel",
        "v3"
    ]
}