Show a patch.

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

{
    "id": 9654,
    "url": "https://patchwork.libcamera.org/api/patches/9654/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9654/",
    "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": "<20200918094233.5273-10-naush@raspberrypi.com>",
    "date": "2020-09-18T09:42:30",
    "name": "[libcamera-devel,v8,09/12] libcamera: pipeline: ipa: raspberrypi: Remove use of FrameBuffer cookie",
    "commit_ref": "f22ffc0ebec40e718325922edc3422bf0c487390",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e482d07b25c2cb5293e2110202c544f43d768fb8",
    "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/9654/mbox/",
    "series": [
        {
            "id": 1295,
            "url": "https://patchwork.libcamera.org/api/series/1295/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1295",
            "date": "2020-09-18T09:42:21",
            "name": "Zero-copy RAW stream work",
            "version": 8,
            "mbox": "https://patchwork.libcamera.org/series/1295/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9654/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9654/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 589AAC3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Sep 2020 09:44:06 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 174F062FD1;\n\tFri, 18 Sep 2020 11:44:06 +0200 (CEST)",
            "from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DEEC62FC1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Sep 2020 11:44:04 +0200 (CEST)",
            "by mail-wr1-x435.google.com with SMTP id x14so4923085wrl.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Sep 2020 02:44:04 -0700 (PDT)",
            "from naushir-VirtualBox.pitowers.org\n\t([2a00:1098:3142:14:a00:27ff:fe4d:f6a2])\n\tby smtp.gmail.com with ESMTPSA id\n\tn2sm4792472wma.29.2020.09.18.02.44.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 18 Sep 2020 02:44:02 -0700 (PDT)"
        ],
        "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=\"Mu9DPTGW\"; 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=ZgkjYrRlb6RnGOD3nqFpnULCo+StRs9OlxWaznIBygQ=;\n\tb=Mu9DPTGWEe2p/GVu9CyXXMqKaV1RrPUgdE1f2BEOM9gd3pMTyFZVZpL1Fnc0yDIcoE\n\twC/PNkP0sqfLp5TA67ckZpu8SyIbt4AMt1BzdK8g5pDY3m5hjay3WMYtuRU6ad1k+a2V\n\tiXgL+72KZb7s6kDTi+9/SJH3H+tYtGw1PtI59DEkKFX26Jmll7viCDtTh7/oKnFfGX1r\n\tmzqIZun2MNKIZl9F23cNIYh5VoWwygGyuO7DiCGA5QcSHOgUZxa2jhovXyzHmtPIGXlq\n\tf3uHpFQHL2y/4euDLgHRlWLhEeDh9fqfGWPGsS99x9l7mflyc/3fqpbrz/wY/OxFQSUD\n\tgEHw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\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=ZgkjYrRlb6RnGOD3nqFpnULCo+StRs9OlxWaznIBygQ=;\n\tb=TWgMFeblLOxmr5gerlEzaKZ3IBaA9vLuiEr4DnOzPjxWqVHpA0cS+ta1j26wvH5AKe\n\tXgKrfxLTk8hO1WbfIwXcLLVzf1vgSkJqPQcw+2Tq0atiTDKSElScbLx539oeCOvL+0YR\n\tk2mGEmtvFzRCh9sKrKntT8LEGx9l6ZyWOeJR0orFOGosQULXtWBW0EqkJ7mLQHLVVO0B\n\tcdjU1xK0DKgalgJ++kA6qD/EV9GMAC3uncz1ncnSdJt9IGnInc/mcf1o1JRzK+j64RQZ\n\tefnSxFh4FDdcHGPlX4SnYFNnF3sFEm9LT+WFfTt382SqAptyOauwbFSgoXPqYSsS6Cij\n\tclzQ==",
        "X-Gm-Message-State": "AOAM530uRyNVSuKguAOWWL3E9s7PTYJB+gslD0hDgBEAg43n7Hn8luKC\n\t/faw36Ci13lPA8hP55jE59YYIZVGL1TtvQ==",
        "X-Google-Smtp-Source": "ABdhPJwtsk9lj8I7nZ4Fc/qim+RHEoB1EVKG8BzDauyxZVvkFwq3cW+/8sjUkqjuCUQzUoY36fi7iQ==",
        "X-Received": "by 2002:a5d:40cd:: with SMTP id\n\tb13mr36981648wrq.297.1600422243736; \n\tFri, 18 Sep 2020 02:44:03 -0700 (PDT)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 18 Sep 2020 10:42:30 +0100",
        "Message-Id": "<20200918094233.5273-10-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200918094233.5273-1-naush@raspberrypi.com>",
        "References": "<20200918094233.5273-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v8 09/12] libcamera: pipeline: ipa:\n\traspberrypi: Remove use of FrameBuffer cookie",
        "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=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The FrameBuffer cookie may be set by the application, so this cannot\nbe set by the pipeline handler as well. Revert to using a simple index\ninto the buffer list to identify buffers passing to and from the IPA.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 60 ++++++++++---------\n .../pipeline/raspberrypi/rpi_stream.cpp       | 14 +++--\n .../pipeline/raspberrypi/rpi_stream.h         |  2 +-\n 3 files changed, 40 insertions(+), 36 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 3caf3655..7d91188c 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -890,7 +890,8 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n {\n \tRPiCameraData *data = cameraData(camera);\n-\tint count, ret;\n+\tunsigned int index;\n+\tint ret;\n \n \t/*\n \t * Decide how many internal buffers to allocate. For now, simply look\n@@ -910,30 +911,24 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t}\n \n \t/*\n-\t * Add cookies to the ISP Input buffers so that we can link them with\n-\t * the IPA and RPI_IPA_EVENT_SIGNAL_ISP_PREPARE event.\n-\t */\n-\tcount = 0;\n-\tfor (auto const &b : data->unicam_[Unicam::Image].getBuffers()) {\n-\t\tb->setCookie(count++);\n-\t}\n-\n-\t/*\n-\t * Add cookies to the stats and embedded data buffers and link them with\n-\t * the IPA.\n+\t * Link the FrameBuffers with the index of their position in the vector\n+\t * stored in the RPi stream object.\n+\t *\n+\t * This will allow us to identify buffers passed between the pipeline\n+\t * handler and the IPA.\n \t */\n-\tcount = 0;\n+\tindex = 0;\n \tfor (auto const &b : data->isp_[Isp::Stats].getBuffers()) {\n-\t\tb->setCookie(count++);\n-\t\tdata->ipaBuffers_.push_back({ .id = RPiIpaMask::STATS | b->cookie(),\n+\t\tdata->ipaBuffers_.push_back({ .id = RPiIpaMask::STATS | index,\n \t\t\t\t\t      .planes = b->planes() });\n+\t\tindex++;\n \t}\n \n-\tcount = 0;\n+\tindex = 0;\n \tfor (auto const &b : data->unicam_[Unicam::Embedded].getBuffers()) {\n-\t\tb->setCookie(count++);\n-\t\tdata->ipaBuffers_.push_back({ .id = RPiIpaMask::EMBEDDED_DATA | b->cookie(),\n+\t\tdata->ipaBuffers_.push_back({ .id = RPiIpaMask::EMBEDDED_DATA | index,\n \t\t\t\t\t      .planes = b->planes() });\n+\t\tindex++;\n \t}\n \n \tdata->ipa_->mapBuffers(data->ipaBuffers_);\n@@ -1106,7 +1101,7 @@ void RPiCameraData::queueFrameAction([[maybe_unused]] unsigned int frame,\n \t\tunsigned int bufferId = action.data[0];\n \t\tFrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId);\n \n-\t\tLOG(RPI, Debug) << \"Input re-queue to ISP, buffer id \" << buffer->cookie()\n+\t\tLOG(RPI, Debug) << \"Input re-queue to ISP, buffer id \" << bufferId\n \t\t\t\t<< \", timestamp: \" << buffer->metadata().timestamp;\n \n \t\tisp_[Isp::Input].queueBuffer(buffer);\n@@ -1126,12 +1121,14 @@ done:\n void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n {\n \tRPi::RPiStream *stream = nullptr;\n+\tint index;\n \n \tif (state_ == State::Stopped)\n \t\treturn;\n \n \tfor (RPi::RPiStream &s : unicam_) {\n-\t\tif (s.findFrameBuffer(buffer)) {\n+\t\tindex = s.getBufferIndex(buffer);\n+\t\tif (index != -1) {\n \t\t\tstream = &s;\n \t\t\tbreak;\n \t\t}\n@@ -1141,7 +1138,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n \tASSERT(stream);\n \n \tLOG(RPI, Debug) << \"Stream \" << stream->name() << \" buffer dequeue\"\n-\t\t\t<< \", buffer id \" << buffer->cookie()\n+\t\t\t<< \", buffer id \" << index\n \t\t\t<< \", timestamp: \" << buffer->metadata().timestamp;\n \n \tif (stream == &unicam_[Unicam::Image]) {\n@@ -1181,7 +1178,7 @@ void RPiCameraData::ispInputDequeue(FrameBuffer *buffer)\n \t\treturn;\n \n \tLOG(RPI, Debug) << \"Stream ISP Input buffer complete\"\n-\t\t\t<< \", buffer id \" << buffer->cookie()\n+\t\t\t<< \", buffer id \" << unicam_[Unicam::Image].getBufferIndex(buffer)\n \t\t\t<< \", timestamp: \" << buffer->metadata().timestamp;\n \n \t/* The ISP input buffer gets re-queued into Unicam. */\n@@ -1192,12 +1189,14 @@ void RPiCameraData::ispInputDequeue(FrameBuffer *buffer)\n void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)\n {\n \tRPi::RPiStream *stream = nullptr;\n+\tint index;\n \n \tif (state_ == State::Stopped)\n \t\treturn;\n \n \tfor (RPi::RPiStream &s : isp_) {\n-\t\tif (s.findFrameBuffer(buffer)) {\n+\t\tindex = s.getBufferIndex(buffer);\n+\t\tif (index != -1) {\n \t\t\tstream = &s;\n \t\t\tbreak;\n \t\t}\n@@ -1207,7 +1206,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)\n \tASSERT(stream);\n \n \tLOG(RPI, Debug) << \"Stream \" << stream->name() << \" buffer complete\"\n-\t\t\t<< \", buffer id \" << buffer->cookie()\n+\t\t\t<< \", buffer id \" << index\n \t\t\t<< \", timestamp: \" << buffer->metadata().timestamp;\n \n \t/*\n@@ -1217,7 +1216,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)\n \tif (stream == &isp_[Isp::Stats]) {\n \t\tIPAOperationData op;\n \t\top.operation = RPI_IPA_EVENT_SIGNAL_STAT_READY;\n-\t\top.data = { RPiIpaMask::STATS | buffer->cookie() };\n+\t\top.data = { RPiIpaMask::STATS | static_cast<unsigned int>(index) };\n \t\tipa_->processEvent(op);\n \t} else {\n \t\t/* Any other ISP output can be handed back to the application now. */\n@@ -1437,13 +1436,16 @@ void RPiCameraData::tryRunPipeline()\n \t/* Set our state to say the pipeline is active. */\n \tstate_ = State::Busy;\n \n+\tunsigned int bayerIndex = unicam_[Unicam::Image].getBufferIndex(bayerBuffer);\n+\tunsigned int embeddedIndex = unicam_[Unicam::Embedded].getBufferIndex(embeddedBuffer);\n+\n \tLOG(RPI, Debug) << \"Signalling RPI_IPA_EVENT_SIGNAL_ISP_PREPARE:\"\n-\t\t\t<< \" Bayer buffer id: \" << bayerBuffer->cookie()\n-\t\t\t<< \" Embedded buffer id: \" << embeddedBuffer->cookie();\n+\t\t\t<< \" Bayer buffer id: \" << bayerIndex\n+\t\t\t<< \" Embedded buffer id: \" << embeddedIndex;\n \n \top.operation = RPI_IPA_EVENT_SIGNAL_ISP_PREPARE;\n-\top.data = { RPiIpaMask::EMBEDDED_DATA | embeddedBuffer->cookie(),\n-\t\t    RPiIpaMask::BAYER_DATA | bayerBuffer->cookie() };\n+\top.data = { RPiIpaMask::EMBEDDED_DATA | embeddedIndex,\n+\t\t    RPiIpaMask::BAYER_DATA | bayerIndex };\n \tipa_->processEvent(op);\n }\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\nindex b2a5dfa7..80170d64 100644\n--- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\n@@ -53,15 +53,17 @@ const std::vector<FrameBuffer *> &RPiStream::getBuffers() const\n \treturn bufferList_;\n }\n \n-bool RPiStream::findFrameBuffer(FrameBuffer *buffer) const\n+int RPiStream::getBufferIndex(FrameBuffer *buffer) const\n {\n \tif (importOnly_)\n-\t\treturn false;\n+\t\treturn -1;\n \n-\tif (std::find(bufferList_.begin(), bufferList_.end(), buffer) != bufferList_.end())\n-\t\treturn true;\n+\t/* Find the buffer in the list, and return the index position. */\n+\tauto it = std::find(bufferList_.begin(), bufferList_.end(), buffer);\n+\tif (it != bufferList_.end())\n+\t\treturn std::distance(bufferList_.begin(), it);\n \n-\treturn false;\n+\treturn -1;\n }\n \n int RPiStream::prepareBuffers(unsigned int count)\n@@ -199,7 +201,7 @@ void RPiStream::clearBuffers()\n \n int RPiStream::queueToDevice(FrameBuffer *buffer)\n {\n-\tLOG(RPISTREAM, Debug) << \"Queuing buffer \" << buffer->cookie()\n+\tLOG(RPISTREAM, Debug) << \"Queuing buffer \" << getBufferIndex(buffer)\n \t\t\t      << \" for \" << name_;\n \n \tint ret = dev_->queueBuffer(buffer);\ndiff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.h b/src/libcamera/pipeline/raspberrypi/rpi_stream.h\nindex f42e25b9..959e9147 100644\n--- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h\n+++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h\n@@ -46,7 +46,7 @@ public:\n \n \tvoid setExportedBuffers(std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \tconst std::vector<FrameBuffer *> &getBuffers() const;\n-\tbool findFrameBuffer(FrameBuffer *buffer) const;\n+\tint getBufferIndex(FrameBuffer *buffer) const;\n \n \tint prepareBuffers(unsigned int count);\n \tint queueBuffer(FrameBuffer *buffer);\n",
    "prefixes": [
        "libcamera-devel",
        "v8",
        "09/12"
    ]
}