Patch Detail
Show a patch.
GET /api/1.1/patches/8871/?format=api
{ "id": 8871, "url": "https://patchwork.libcamera.org/api/1.1/patches/8871/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8871/", "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": "<20200720091311.805092-10-naush@raspberrypi.com>", "date": "2020-07-20T09:13:11", "name": "[libcamera-devel,v4,9/9] libcamera: pipeline: ipa: raspberrypi: Remove use of FrameBuffer cookie", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "e7d99741e85cc02f0ef95d7bd5ad71fed3a10e3a", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/8871/mbox/", "series": [ { "id": 1117, "url": "https://patchwork.libcamera.org/api/1.1/series/1117/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1117", "date": "2020-07-20T09:13:02", "name": "Zero-copy RAW stream work", "version": 4, "mbox": "https://patchwork.libcamera.org/series/1117/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8871/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8871/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 ECD82C2E67\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jul 2020 09:13:39 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B5A8B6071A;\n\tMon, 20 Jul 2020 11:13:39 +0200 (CEST)", "from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C83060740\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jul 2020 11:13:36 +0200 (CEST)", "by mail-wr1-x42f.google.com with SMTP id o11so17044281wrv.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jul 2020 02:13:36 -0700 (PDT)", "from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tu1sm38137185wrb.78.2020.07.20.02.13.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 20 Jul 2020 02:13:34 -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=\"oy0Lqf0k\"; 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=Duv/Vjlm7mcp+9mCFKeMyXs8naSwOJ+ashD0v9Kh0ps=;\n\tb=oy0Lqf0ko68LkZcj9Qk5AjcS7MWMG+EW05Wj+AmXG/VC/N9NQxmGnxtkGA0QBWwRlh\n\tEitcSdkkVi/frGE4+HQa6D1BUosLPyFp/1b6dDywMOWOJ1hC6zAZwL6bKamfHx9Rt39t\n\tfUlxOJHj+Tu994aUJHTk0B5bNvUFkJ0cNTUQ6NURKjFPaEIiuQ9DWVTBv5bD0R3PE/bm\n\tmTwjHmEqYTldVSJAjD5Co+aU6sQu7YLn3qJH0rlBtC+qN/2P9uXPKUDJ2qlzmOzg4KBS\n\t/nYHA5GHJLUp/kjJhXQDqOffbrXjnWJPe1XYNOD/xPx44weJzQgOG5vUT1EagCyPK4u9\n\tnx/A==", "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=Duv/Vjlm7mcp+9mCFKeMyXs8naSwOJ+ashD0v9Kh0ps=;\n\tb=ma8Z4Bg8tMOcFiR+qfK+3vRcC2rdConvkmYNM2lYkl8MRsbBhxBvbVyzoWC+crlwny\n\tQ0rwrQj30u/DeXPCt0/gJwQMcjlBFDrcDexAoKF0W+cvmTNQTQ1lSw6fCQybgXbZWpnS\n\t2rka23JXideOVX1bGRJ0f8g3CvFSntVgHjACMsSVY/HAeH1koqQ77c8eNePUn5jhTyZW\n\tip7Pm2u94toeKwZGJNRfEZHUiR1NkC7I33KfmX6XjlLKAUKk3mrWH0al7VFW3lVUeP85\n\tn+Ch0buFnscrTc2MQeZ/T50SL0Uqkn2uZz2B2dvo9ehdg2zAPKdnD6VK0Em5J9ckmCh7\n\t0MWw==", "X-Gm-Message-State": "AOAM533OO2/nGMmblJAtllQ+DtfLtjwDIYIx/BK1TWXy5+j9nMfYyE/w\n\teoD5mW9JTpBEMY9qKqllHuVgbeY5Am0IvQ==", "X-Google-Smtp-Source": "ABdhPJzY2MYM54nK7JsQTH21hc9cN/QVym+AaA0MP89GtsWQK7GsBlF/kDxLFBFDP1KJIZE0dn3LfQ==", "X-Received": "by 2002:adf:d08d:: with SMTP id\n\ty13mr1017446wrh.313.1595236415487; \n\tMon, 20 Jul 2020 02:13:35 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 20 Jul 2020 10:13:11 +0100", "Message-Id": "<20200720091311.805092-10-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20200720091311.805092-1-naush@raspberrypi.com>", "References": "<20200720091311.805092-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v4 9/9] 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>\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 c28fe997..e4fc5ac7 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -876,7 +876,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@@ -896,30 +897,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@@ -1097,7 +1092,7 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\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@@ -1117,12 +1112,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@@ -1132,7 +1129,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@@ -1172,7 +1169,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@@ -1183,12 +1180,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@@ -1198,7 +1197,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@@ -1208,7 +1207,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@@ -1427,13 +1426,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 6635a751..73eb04a1 100644\n--- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\n@@ -178,15 +178,17 @@ void RPiStream::returnBuffer(FrameBuffer *buffer)\n \t}\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 void RPiStream::clearBuffers()\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 6222c867..45cf5237 100644\n--- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h\n+++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h\n@@ -48,7 +48,7 @@ public:\n \tint queueAllBuffers();\n \tint queueBuffer(FrameBuffer *buffer);\n \tvoid returnBuffer(FrameBuffer *buffer);\n-\tbool findFrameBuffer(FrameBuffer *buffer) const;\n+\tint getBufferIndex(FrameBuffer *buffer) const;\n \n private:\n \tvoid clearBuffers();\n", "prefixes": [ "libcamera-devel", "v4", "9/9" ] }