Patch Detail
Show a patch.
GET /api/patches/26289/?format=api
{ "id": 26289, "url": "https://patchwork.libcamera.org/api/patches/26289/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26289/", "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": "<20260313-mali-cru-v4-6-c0d9bc8cd8fa@ideasonboard.com>", "date": "2026-03-13T11:33:47", "name": "[v4,6/7] libcamera: mali-c55: Implement capture for memory-to-memory", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "2f5422de3aa279327014d3a130964742a997671a", "submitter": { "id": 143, "url": "https://patchwork.libcamera.org/api/people/143/?format=api", "name": "Jacopo Mondi", "email": "jacopo.mondi@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26289/mbox/", "series": [ { "id": 5829, "url": "https://patchwork.libcamera.org/api/series/5829/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5829", "date": "2026-03-13T11:33:41", "name": "libcamera: mali-c55: Add support for memory-to-memory", "version": 4, "mbox": "https://patchwork.libcamera.org/series/5829/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26289/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26289/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 1AB1ABE086\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Mar 2026 11:34:34 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C22D7626CC;\n\tFri, 13 Mar 2026 12:34:33 +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 9982B626BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Mar 2026 12:34:31 +0100 (CET)", "from [192.168.224.131] (unknown [37.159.92.229])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 30F85F52;\n\tFri, 13 Mar 2026 12:33:21 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"kjeNef8R\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1773401602;\n\tbh=Pu5vGFdppL5hYCM49zYblomenvaxGbY4rr9u/hv8H2k=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=kjeNef8RqafOwt1SwHg6fvWcYkVas8PpoUPYwKqPOR4Nbw3LgQRrL6z0VO7XnVcqH\n\tA8mbWyGb2M26/N6lkvK2LSnB5XEfZl9xkIDXm/gi2YqnOoQu8ihBMO9+WmggoNZpnG\n\twGN2DL72+Ncv0M5tfz/a0M3Rsq/TjXLsIIPbfzMc=", "From": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Date": "Fri, 13 Mar 2026 12:33:47 +0100", "Subject": "[PATCH v4 6/7] libcamera: mali-c55: Implement capture for\n\tmemory-to-memory", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260313-mali-cru-v4-6-c0d9bc8cd8fa@ideasonboard.com>", "References": "<20260313-mali-cru-v4-0-c0d9bc8cd8fa@ideasonboard.com>", "In-Reply-To": "<20260313-mali-cru-v4-0-c0d9bc8cd8fa@ideasonboard.com>", "To": "Daniel Scally <dan.scally@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "X-Mailer": "b4 0.14.3", "X-Developer-Signature": "v=1; a=openpgp-sha256; l=9435;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=9BNJlLRoxEiMcYg3pm6FhwrkFt9rU7wwZfV5nbZEg4c=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBps/Y1X3Nwyt4uEDhacT4yBW3AKraGSnwdzMAz0\n\tI9wras/uZKJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCabP2NQAKCRByNAaPFqFW\n\tPM/xD/9l8Pycyu+DjzLAfvl2jQWoL46yRRHTcHRaquFuvQ/cJBlOHYJl4lCcNCJadrBa1okPSAc\n\ttb8XYn0KkL/vvKxKmGebddERc7ywWrUHiZCPJeNYyhZ4nCLFKGYtBU3nsCbCHdRXqAdce/qsKwa\n\tNwUzil9ghRQZiaPW2VR+loSfwejJx/QXkuvCw/14FYw/rJv9LDxFGKqf1faYdzHIggYh/phDIiB\n\t7jE11eDLQBgD+G3LNs96wDDVWsVfU6dqZdBmtIztVc7/XX5KwAaC0khQ5qUXXWEGwsQNcTrp8g+\n\tO2FNW0qKskVdWe7m5nopfX5X9jHHdQefpkRPCOUFhLnbVtQ0Eh800LFHZlsiZ48ON0T1BPei1rq\n\tIeBc8GtbLElSs3KIKAyV3tFXrIUZoWBjw8N6MNLyXSgI1+VxM7CihPYakvPHkCHDKM9cNbJmSSa\n\to6o6D4/tyq8+ln5P8+yxXXDg8FyKiidXQO0uUxlEo13+NKhgem1mssUzg9MSz0R0CrG8slYxNG9\n\tmkwhWuReA3L0EEgL3u7ayhNvNNrpMjeor7GtmSMse95wZenLcvu6dMjvNhLCilIecAPsnSgRyk4\n\tcvX0Rrsoy3BWN6Xgs4iRLYhzW2S435xV56vqEby46t33UuMfBqACCcRJ0XcHUVH1CK1rm8euxet\n\trd0lU5g86CouA7Q==", "X-Developer-Key": "i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B", "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": "From: Daniel Scally <dan.scally@ideasonboard.com>\n\nPlumb in the MaliC55 pipeline handler support for capturing frames\nfrom memory using the CRU.\n\nIntroduce a data flow which uses the CRU to feed the ISP through\nthe IVC.\n\nIn detail:\n\n- push incoming request to a pending queue until a buffer from the CRU\n is available\n- delay the call to ipa_->fillParams() to the CRU buffer ready even\n- once the IPA has computed parameters feed the ISP through the IVC\n with buffers from the CRU, params and statistics.\n\nSigned-off-by: Daniel Scally <dan.scally@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/libcamera/pipeline/mali-c55/mali-c55.cpp | 166 ++++++++++++++++++++++++++-\n 1 file changed, 161 insertions(+), 5 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\nindex 575c8451fc4f..a2f8f4b8e881 100644\n--- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n+++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n@@ -21,6 +21,7 @@\n #include <libcamera/base/utils.h>\n \n #include <libcamera/camera.h>\n+#include <libcamera/controls.h>\n #include <libcamera/formats.h>\n #include <libcamera/geometry.h>\n #include <libcamera/property_ids.h>\n@@ -88,6 +89,7 @@ struct MaliC55FrameInfo {\n \n \tFrameBuffer *paramBuffer;\n \tFrameBuffer *statBuffer;\n+\tFrameBuffer *rawBuffer;\n \n \tbool paramsDone;\n \tbool statsDone;\n@@ -721,11 +723,14 @@ public:\n \tint start(Camera *camera, const ControlList *controls) override;\n \tvoid stopDevice(Camera *camera) override;\n \n+\tint queuePendingRequests(MaliC55CameraData *data);\n+\tvoid cancelPendingRequests();\n \tint queueRequestDevice(Camera *camera, Request *request) override;\n \n \tvoid imageBufferReady(FrameBuffer *buffer);\n \tvoid paramsBufferReady(FrameBuffer *buffer);\n \tvoid statsBufferReady(FrameBuffer *buffer);\n+\tvoid cruBufferReady(FrameBuffer *buffer);\n \tvoid paramsComputed(unsigned int requestId, uint32_t bytesused);\n \tvoid statsProcessed(unsigned int requestId, const ControlList &metadata);\n \n@@ -807,6 +812,11 @@ private:\n \n \tstd::map<unsigned int, MaliC55FrameInfo> frameInfoMap_;\n \n+\t/* Requests for which no buffer has been queued to the CRU device yet. */\n+\tstd::queue<Request *> pendingRequests_;\n+\t/* Requests queued to the CRU device but not yet processed by the ISP. */\n+\tstd::queue<Request *> processingRequests_;\n+\n \tstd::array<MaliC55Pipe, MaliC55NumPipes> pipes_;\n \n \tbool dsFitted_;\n@@ -1249,6 +1259,11 @@ void PipelineHandlerMaliC55::freeBuffers(Camera *camera)\n \tif (params_->releaseBuffers())\n \t\tLOG(MaliC55, Error) << \"Failed to release params buffers\";\n \n+\tif (std::holds_alternative<MaliC55CameraData::Memory>(data->input_)) {\n+\t\tif (ivc_->releaseBuffers())\n+\t\t\tLOG(MaliC55, Error) << \"Failed to release input buffers\";\n+\t}\n+\n \treturn;\n }\n \n@@ -1278,6 +1293,12 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera)\n \t\t}\n \t};\n \n+\tif (std::holds_alternative<MaliC55CameraData::Memory>(data->input_)) {\n+\t\tret = ivc_->importBuffers(RZG2LCRU::kBufferCount);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t}\n+\n \tret = stats_->allocateBuffers(bufferCount, &statsBuffers_);\n \tif (ret < 0)\n \t\treturn ret;\n@@ -1309,6 +1330,24 @@ int PipelineHandlerMaliC55::start(Camera *camera, [[maybe_unused]] const Control\n \tif (ret)\n \t\treturn ret;\n \n+\tif (std::holds_alternative<MaliC55CameraData::Memory>(data->input_)) {\n+\t\tret = data->cru()->start();\n+\t\tif (ret) {\n+\t\t\tLOG(MaliC55, Error)\n+\t\t\t\t<< \"Failed to start CRU \" << camera->id();\n+\t\t\tfreeBuffers(camera);\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\tret = ivc_->streamOn();\n+\t\tif (ret) {\n+\t\t\tLOG(MaliC55, Error)\n+\t\t\t\t<< \"Failed to start IVC\" << camera->id();\n+\t\t\tfreeBuffers(camera);\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n \tif (data->ipa_) {\n \t\tret = data->ipa_->start();\n \t\tif (ret) {\n@@ -1398,6 +1437,12 @@ void PipelineHandlerMaliC55::stopDevice(Camera *camera)\n \t\tpipe.cap->releaseBuffers();\n \t}\n \n+\tif (std::holds_alternative<MaliC55CameraData::Memory>(data->input_)) {\n+\t\tcancelPendingRequests();\n+\t\tivc_->streamOff();\n+\t\tdata->cru()->stop();\n+\t}\n+\n \tstats_->streamOff();\n \tparams_->streamOff();\n \tif (data->ipa_)\n@@ -1501,10 +1546,88 @@ void PipelineHandlerMaliC55::applyScalerCrop(Camera *camera,\n \t}\n }\n \n+void PipelineHandlerMaliC55::cancelPendingRequests()\n+{\n+\tprocessingRequests_ = {};\n+\n+\twhile (!pendingRequests_.empty()) {\n+\t\tRequest *request = pendingRequests_.front();\n+\n+\t\tcompleteRequest(request);\n+\t\tpendingRequests_.pop();\n+\t}\n+}\n+\n+int PipelineHandlerMaliC55::queuePendingRequests(MaliC55CameraData *data)\n+{\n+\tASSERT(std::holds_alternative<MaliC55CameraData::Memory>(data->input_));\n+\n+\twhile (!pendingRequests_.empty()) {\n+\t\tRequest *request = pendingRequests_.front();\n+\n+\t\tif (availableStatsBuffers_.empty()) {\n+\t\t\tLOG(MaliC55, Error) << \"Stats buffer underrun\";\n+\t\t\treturn -ENOENT;\n+\t\t}\n+\n+\t\tif (availableParamsBuffers_.empty()) {\n+\t\t\tLOG(MaliC55, Error) << \"Params buffer underrun\";\n+\t\t\treturn -ENOENT;\n+\t\t}\n+\n+\t\tMaliC55FrameInfo frameInfo;\n+\t\tframeInfo.request = request;\n+\n+\t\tframeInfo.rawBuffer = data->cru()->queueBuffer(request);\n+\t\tif (!frameInfo.rawBuffer)\n+\t\t\treturn -ENOENT;\n+\n+\t\tframeInfo.statBuffer = availableStatsBuffers_.front();\n+\t\tavailableStatsBuffers_.pop();\n+\t\tframeInfo.paramBuffer = availableParamsBuffers_.front();\n+\t\tavailableParamsBuffers_.pop();\n+\n+\t\tframeInfo.paramsDone = false;\n+\t\tframeInfo.statsDone = false;\n+\n+\t\tframeInfoMap_[request->sequence()] = frameInfo;\n+\n+\t\tfor (auto &[stream, buffer] : request->buffers()) {\n+\t\t\tMaliC55Pipe *pipe = pipeFromStream(data, stream);\n+\n+\t\t\tpipe->cap->queueBuffer(buffer);\n+\t\t}\n+\n+\t\tdata->ipa_->queueRequest(request->sequence(), request->controls());\n+\n+\t\tpendingRequests_.pop();\n+\t\tprocessingRequests_.push(request);\n+\t}\n+\n+\treturn 0;\n+}\n+\n int PipelineHandlerMaliC55::queueRequestDevice(Camera *camera, Request *request)\n {\n \tMaliC55CameraData *data = cameraData(camera);\n \n+\t/*\n+\t * If we're in memory input mode, we need to pop the requests onto the\n+\t * pending list until a CRU buffer is ready...otherwise we can just do\n+\t * everything immediately.\n+\t */\n+\tif (std::holds_alternative<MaliC55CameraData::Memory>(data->input_)) {\n+\t\tpendingRequests_.push(request);\n+\n+\t\tint ret = queuePendingRequests(data);\n+\t\tif (ret) {\n+\t\t\tpendingRequests_.pop();\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\treturn 0;\n+\t}\n+\n \t/* Do not run the IPA if the TPG is in use. */\n \tif (!data->ipa_) {\n \t\tMaliC55FrameInfo frameInfo;\n@@ -1569,7 +1692,8 @@ MaliC55FrameInfo *PipelineHandlerMaliC55::findFrameInfo(FrameBuffer *buffer)\n {\n \tfor (auto &[sequence, info] : frameInfoMap_) {\n \t\tif (info.paramBuffer == buffer ||\n-\t\t info.statBuffer == buffer)\n+\t\t info.statBuffer == buffer ||\n+\t\t info.rawBuffer == buffer)\n \t\t\treturn &info;\n \t}\n \n@@ -1631,6 +1755,26 @@ void PipelineHandlerMaliC55::statsBufferReady(FrameBuffer *buffer)\n \t\t\t\t sensorControls);\n }\n \n+void PipelineHandlerMaliC55::cruBufferReady(FrameBuffer *buffer)\n+{\n+\tMaliC55FrameInfo *info = findFrameInfo(buffer);\n+\tRequest *request = info->request;\n+\tASSERT(info);\n+\n+\tif (buffer->metadata().status == FrameMetadata::FrameCancelled) {\n+\t\tframeInfoMap_.erase(request->sequence());\n+\t\tcompleteRequest(request);\n+\t\treturn;\n+\t}\n+\n+\trequest->_d()->metadata().set(controls::SensorTimestamp,\n+\t\t\t\t buffer->metadata().timestamp);\n+\n+\t/* Ought we do something with the sensor's controls here...? */\n+\tMaliC55CameraData *data = cameraData(request->_d()->camera());\n+\tdata->ipa_->fillParams(request->sequence(), info->paramBuffer->cookie());\n+}\n+\n void PipelineHandlerMaliC55::paramsComputed(unsigned int requestId, uint32_t bytesused)\n {\n \tMaliC55FrameInfo &frameInfo = frameInfoMap_[requestId];\n@@ -1639,18 +1783,27 @@ void PipelineHandlerMaliC55::paramsComputed(unsigned int requestId, uint32_t byt\n \n \t/*\n \t * Queue buffers for stats and params, then queue buffers to the capture\n-\t * video devices.\n+\t * video devices if we're running in Inline mode or with the TPG.\n+\t *\n+\t * If we're running in M2M buffers have been queued to the capture\n+\t * devices at queuePendingRequests() time and here we only have to queue\n+\t * buffers to the IVC input to start a transfer.\n \t */\n \n \tframeInfo.paramBuffer->_d()->metadata().planes()[0].bytesused = bytesused;\n \tparams_->queueBuffer(frameInfo.paramBuffer);\n \tstats_->queueBuffer(frameInfo.statBuffer);\n \n-\tfor (auto &[stream, buffer] : request->buffers()) {\n-\t\tMaliC55Pipe *pipe = pipeFromStream(data, stream);\n+\tif (!std::holds_alternative<MaliC55CameraData::Memory>(data->input_)) {\n+\t\tfor (auto &[stream, buffer] : request->buffers()) {\n+\t\t\tMaliC55Pipe *pipe = pipeFromStream(data, stream);\n \n-\t\tpipe->cap->queueBuffer(buffer);\n+\t\t\tpipe->cap->queueBuffer(buffer);\n+\t\t}\n \t}\n+\n+\tif (std::holds_alternative<MaliC55CameraData::Memory>(data->input_))\n+\t\tivc_->queueBuffer(frameInfo.rawBuffer);\n }\n \n void PipelineHandlerMaliC55::statsProcessed(unsigned int requestId,\n@@ -1787,6 +1940,9 @@ bool PipelineHandlerMaliC55::registerMemoryInputCamera()\n \n \tivc_->bufferReady.connect(data->cru(), &RZG2LCRU::cruReturnBuffer);\n \n+\tV4L2VideoDevice *cruOutput = data->cru()->output();\n+\tcruOutput->bufferReady.connect(this, &PipelineHandlerMaliC55::cruBufferReady);\n+\n \treturn registerMaliCamera(std::move(data), sensor->device()->entity()->name());\n }\n \n", "prefixes": [ "v4", "6/7" ] }