Show a patch.

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

{
    "id": 22419,
    "url": "https://patchwork.libcamera.org/api/patches/22419/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22419/",
    "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": "<20241219211010.103310-2-mzamazal@redhat.com>",
    "date": "2024-12-19T21:10:06",
    "name": "[v2,1/5] libcamera: software_isp: Track frames and requests",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "df6b1baf17734a5c769d8cc542cfa6a56c6318ba",
    "submitter": {
        "id": 177,
        "url": "https://patchwork.libcamera.org/api/people/177/?format=api",
        "name": "Milan Zamazal",
        "email": "mzamazal@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22419/mbox/",
    "series": [
        {
            "id": 4920,
            "url": "https://patchwork.libcamera.org/api/series/4920/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4920",
            "date": "2024-12-19T21:10:05",
            "name": "ipa: simple: Introduce metadata reporting",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4920/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22419/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22419/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 C49C4BD7D8\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Dec 2024 21:10:31 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 412D868483;\n\tThu, 19 Dec 2024 22:10:31 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E16368471\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Dec 2024 22:10:28 +0100 (CET)",
            "from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-78-xm_P_HR-OiWtVuhrJBPyGg-1;\n\tThu, 19 Dec 2024 16:10:25 -0500",
            "from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id C95A91956046; Thu, 19 Dec 2024 21:10:24 +0000 (UTC)",
            "from nuthatch.redhat.com (unknown [10.45.224.37])\n\tby mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id E8B0730044C1; Thu, 19 Dec 2024 21:10:22 +0000 (UTC)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"iOfRrU84\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1734642627;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=EMGQn+N/13YiKmyFMD99W6zD+mBu5cFtDRapzLfd4oc=;\n\tb=iOfRrU84ViiH5MPfhXlbNgyy0OhfmfvQDLzP7PrU6K/3ZcLd4Ngs52teSBUu9xwc0Q96pP\n\t/JuLdYMdwIaiIl1kLv7H15JfNlaqFZTNC38CAzziHdmNwA89E8Rr/bBdfDn4Wqs8h7j6dQ\n\tApEqimKmT2pmHNLUKeR7YZ3yUL2w+fU=",
        "X-MC-Unique": "xm_P_HR-OiWtVuhrJBPyGg-1",
        "X-Mimecast-MFC-AGG-ID": "xm_P_HR-OiWtVuhrJBPyGg",
        "From": "Milan Zamazal <mzamazal@redhat.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Milan Zamazal <mzamazal@redhat.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Subject": "[PATCH v2 1/5] libcamera: software_isp: Track frames and requests",
        "Date": "Thu, 19 Dec 2024 22:10:06 +0100",
        "Message-ID": "<20241219211010.103310-2-mzamazal@redhat.com>",
        "In-Reply-To": "<20241219211010.103310-1-mzamazal@redhat.com>",
        "References": "<20241219211010.103310-1-mzamazal@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.4",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-MFC-PROC-ID": "J9kojeCltSwfSnkiaVqSzI_Xbq5EiazZRpdzLoL7YLE_1734642624",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "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": "Hardware pipelines track requests and other information related to\nparticular frames.  This hasn't been needed in software ISP so far.  But\nin order to be able to track metadata corresponding to a given frame,\nframe-request tracking mechanism starts being useful.  This patch\nintroduces the basic tracking structure, actual metadata handling is\nadded in the following patch.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 87 ++++++++++++++++++++++--\n 1 file changed, 82 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 8ac24e6e..07c1cf1f 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -181,6 +181,70 @@ LOG_DEFINE_CATEGORY(SimplePipeline)\n \n class SimplePipelineHandler;\n \n+struct SimpleFrameInfo {\n+\tuint32_t frame;\n+\tRequest *request;\n+};\n+\n+class SimpleFrames\n+{\n+public:\n+\tvoid create(Request *request);\n+\tvoid destroy(uint32_t frame);\n+\tvoid clear();\n+\n+\tSimpleFrameInfo *find(uint32_t frame);\n+\tSimpleFrameInfo *find(Request *request);\n+\n+private:\n+\tstd::map<uint32_t, SimpleFrameInfo *> frameInfo_;\n+};\n+\n+void SimpleFrames::create(Request *request)\n+{\n+\tuint32_t frame = request->sequence();\n+\tSimpleFrameInfo *info = new SimpleFrameInfo;\n+\tinfo->frame = frame;\n+\tinfo->request = request;\n+\tframeInfo_[frame] = info;\n+}\n+\n+void SimpleFrames::destroy(uint32_t frame)\n+{\n+\tSimpleFrameInfo *info = find(frame);\n+\tif (!info)\n+\t\treturn;\n+\tdelete info;\n+\tframeInfo_.erase(frame);\n+}\n+\n+void SimpleFrames::clear()\n+{\n+\tfor (const auto &info : frameInfo_)\n+\t\tdelete info.second;\n+\tframeInfo_.clear();\n+}\n+\n+SimpleFrameInfo *SimpleFrames::find(uint32_t frame)\n+{\n+\tauto info = frameInfo_.find(frame);\n+\tif (info == frameInfo_.end())\n+\t\treturn nullptr;\n+\treturn info->second;\n+}\n+\n+SimpleFrameInfo *SimpleFrames::find(Request *request)\n+{\n+\tfor (auto &itInfo : frameInfo_) {\n+\t\tSimpleFrameInfo *info = itInfo.second;\n+\n+\t\tif (info->request == request)\n+\t\t\treturn info;\n+\t}\n+\n+\treturn nullptr;\n+}\n+\n struct SimplePipelineInfo {\n \tconst char *driver;\n \t/*\n@@ -293,11 +357,13 @@ public:\n \n \tstd::unique_ptr<Converter> converter_;\n \tstd::unique_ptr<SoftwareIsp> swIsp_;\n+\tSimpleFrames frameInfo_;\n \n private:\n \tvoid tryPipeline(unsigned int code, const Size &size);\n \tstatic std::vector<const MediaPad *> routedSourcePads(MediaPad *sink);\n \n+\tvoid completeRequest(Request *request);\n \tvoid conversionInputDone(FrameBuffer *buffer);\n \tvoid conversionOutputDone(FrameBuffer *buffer);\n \n@@ -799,7 +865,7 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n \t\t\t/* No conversion, just complete the request. */\n \t\t\tRequest *request = buffer->request();\n \t\t\tpipe->completeBuffer(request, buffer);\n-\t\t\tpipe->completeRequest(request);\n+\t\t\tcompleteRequest(request);\n \t\t\treturn;\n \t\t}\n \n@@ -817,7 +883,7 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n \t\tconst RequestOutputs &outputs = conversionQueue_.front();\n \t\tfor (auto &[stream, buf] : outputs.outputs)\n \t\t\tpipe->completeBuffer(outputs.request, buf);\n-\t\tpipe->completeRequest(outputs.request);\n+\t\tcompleteRequest(outputs.request);\n \t\tconversionQueue_.pop();\n \n \t\treturn;\n@@ -875,7 +941,7 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n \n \t/* Otherwise simply complete the request. */\n \tpipe->completeBuffer(request, buffer);\n-\tpipe->completeRequest(request);\n+\tcompleteRequest(request);\n }\n \n void SimpleCameraData::clearIncompleteRequests()\n@@ -886,6 +952,14 @@ void SimpleCameraData::clearIncompleteRequests()\n \t}\n }\n \n+void SimpleCameraData::completeRequest(Request *request)\n+{\n+\tSimpleFrameInfo *info = frameInfo_.find(request);\n+\tif (info)\n+\t\tframeInfo_.destroy(info->frame);\n+\tpipe()->completeRequest(request);\n+}\n+\n void SimpleCameraData::conversionInputDone(FrameBuffer *buffer)\n {\n \t/* Queue the input buffer back for capture. */\n@@ -899,7 +973,7 @@ void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer)\n \t/* Complete the buffer and the request. */\n \tRequest *request = buffer->request();\n \tif (pipe->completeBuffer(request, buffer))\n-\t\tpipe->completeRequest(request);\n+\t\tcompleteRequest(request);\n }\n \n void SimpleCameraData::ispStatsReady(uint32_t frame, uint32_t bufferId)\n@@ -1412,6 +1486,7 @@ void SimplePipelineHandler::stopDevice(Camera *camera)\n \n \tvideo->bufferReady.disconnect(data, &SimpleCameraData::imageBufferReady);\n \n+\tdata->frameInfo_.clear();\n \tdata->clearIncompleteRequests();\n \tdata->conversionBuffers_.clear();\n \n@@ -1442,8 +1517,10 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request)\n \n \tif (data->useConversion_) {\n \t\tdata->conversionQueue_.push({ request, std::move(buffers) });\n-\t\tif (data->swIsp_)\n+\t\tif (data->swIsp_) {\n+\t\t\tdata->frameInfo_.create(request);\n \t\t\tdata->swIsp_->queueRequest(request->sequence(), request->controls());\n+\t\t}\n \t}\n \n \treturn 0;\n",
    "prefixes": [
        "v2",
        "1/5"
    ]
}