{"id":26340,"url":"https://patchwork.libcamera.org/api/1.1/patches/26340/?format=json","web_url":"https://patchwork.libcamera.org/patch/26340/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260325-mali-cru-v6-6-b16b0c49819a@ideasonboard.com>","date":"2026-03-25T14:44:13","name":"[v6,6/7] libcamera: mali-c55: Implement capture for memory-to-memory","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"6aff6e664eb4b71da39d85eff14a451c2d38682f","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/1.1/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26340/mbox/","series":[{"id":5848,"url":"https://patchwork.libcamera.org/api/1.1/series/5848/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5848","date":"2026-03-25T14:44:07","name":"libcamera: mali-c55: Add support for memory-to-memory","version":6,"mbox":"https://patchwork.libcamera.org/series/5848/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26340/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26340/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 748C5C32F8\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Mar 2026 14:44:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B03376283C;\n\tWed, 25 Mar 2026 15:44:26 +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 B2A246274D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2026 15:44:20 +0100 (CET)","from [192.168.1.104] (net-93-65-100-155.cust.vodafonedsl.it\n\t[93.65.100.155])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AE9211ADE;\n\tWed, 25 Mar 2026 15:43:02 +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=\"l7HOhznP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1774449782;\n\tbh=flq4ge5QIzfQeoUke8dLji5yEiMp+FGTl/TsXLIuW3M=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=l7HOhznPjmwC4thbZvDloByz3yiPN675TqSavFDcBAJz8aKvHgI7ikNonwE0cX8Ef\n\teBlBsws59UrNd4uZYwxOPY5IIoaoVcEKao38PYupNV3hJuYIXdXw8EZUHSmPZbYsJ2\n\tV5OA5Lh5jPWHkSKOnZuGWZgycVwskzNq1bcyz21o=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Wed, 25 Mar 2026 15:44:13 +0100","Subject":"[PATCH v6 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":"<20260325-mali-cru-v6-6-b16b0c49819a@ideasonboard.com>","References":"<20260325-mali-cru-v6-0-b16b0c49819a@ideasonboard.com>","In-Reply-To":"<20260325-mali-cru-v6-0-b16b0c49819a@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Cc":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>","X-Mailer":"b4 0.14.3","X-Developer-Signature":"v=1; a=openpgp-sha256; l=13937;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=pHJmjnkudjHJjFFuc+UJG4KlbidDyD0DgZrmZ5fOwbQ=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpw/TCUWHsn7psmT4Uig1WfvGxmoqC6265FkuOF\n\tiKZBUFJjRuJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCacP0wgAKCRByNAaPFqFW\n\tPE6hD/9yhdTQuOhs4+8fRgqddfkoSm2bOVccSAa/a9yPNvXgI40QdWCbe+v+GIarlKSEhixnmZJ\n\txXVanvKkj7ofWsGHuSXycEgv0f6Z6fxhdV6wEfnOejN8eZV88nTH67l+JfTqhGEB4meB13iiUeG\n\t/0UFrfu7jTsMRwMjtDQ73JvJcbQRqJzTox6Ykooy82ipPxNtaKOdZuoO2ZO1pXJIkfg+4ijci2u\n\tBvXFVSG0LZQJGmqorrU1d7IT9yR1IKgC0NRShDo407vVUBoJg0krnK6KPgfn5n/xQRul88aExWE\n\tr4UZub6DH1Z7Sx5v1U1wjoX46hb3tv4QVzHDblopsuAh7ld3YJKKYTr/x5vUzQ64B0ubKbzTOFb\n\ttl6Kp4HZjoV5pf+bGZOB2eFbB7f0SbFNg6xWwnNgdXiYB26xAMLhX7WDGJfhMmQhPW6aGf8QkjL\n\tYl9dFsQ30EzC9IIF52vU3REFUfUTEE7Djp1dfqFwMboev7G8rH1UcKmtpm1GQtXy2NCgstOhZf2\n\tB9rowozmWz2M++Y9zCMUil1SxXtt63906EvYXBB8T0zcM6Fo2vrTK19dd/dBk7qVZYwXauo2c+B\n\trGf+UPoYJWRUH6c1bSU9r1gzgZJ9Rus7C8RwYgRRd7Llc9xxEIxU/A+hpUg5zChtZKbKkNo2btP\n\t/WGkuiF7PDUBf2A==","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- Handle completion of in-flight requests: in m2m mode buffers are\n  queued earlier to the ISP capture devices. If the camera is stopped\n  these buffers are returned earlier in error state: complete the\n  Request bypassing the IPA operations.\n- As cancelled Requests might now be completed earlier then IPA events,\n  modify the IPA event handler to ignore Requests that have been\n  completed already\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 | 244 +++++++++++++++++++++++----\n 1 file changed, 207 insertions(+), 37 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\nindex be3e38da95ab..10848c412849 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@@ -691,6 +693,7 @@ public:\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@@ -739,7 +742,7 @@ private:\n \n \tMaliC55FrameInfo *findFrameInfo(FrameBuffer *buffer);\n \tMaliC55FrameInfo *findFrameInfo(Request *request);\n-\tvoid tryComplete(MaliC55FrameInfo *info);\n+\tvoid tryComplete(MaliC55FrameInfo *info, bool cancelled = false);\n \n \tint configureRawStream(MaliC55CameraData *data,\n \t\t\t       const StreamConfiguration &config,\n@@ -747,6 +750,11 @@ private:\n \tint configureProcessedStream(MaliC55CameraData *data,\n \t\t\t\t     const StreamConfiguration &config,\n \t\t\t\t     V4L2SubdeviceFormat &subdevFormat);\n+\tvoid cancelPendingRequests();\n+\n+\tMaliC55FrameInfo *\n+\tprepareFrameInfo(Request *request, RZG2LCRU *cru = nullptr);\n+\tint queuePendingRequests(MaliC55CameraData *data);\n \n \tvoid applyScalerCrop(Camera *camera, const ControlList &controls);\n \n@@ -772,6 +780,9 @@ 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+\n \tstd::array<MaliC55Pipe, MaliC55NumPipes> pipes_;\n \n \tbool dsFitted_;\n@@ -1220,6 +1231,13 @@ void PipelineHandlerMaliC55::freeBuffers(Camera *camera)\n \tif (params_->releaseBuffers())\n \t\tLOG(MaliC55, Error) << \"Failed to release params buffers\";\n \n+\tif (auto *mem = std::get_if<MaliC55CameraData::Memory>(&data->input_)) {\n+\t\tif (ivc_->releaseBuffers())\n+\t\t\tLOG(MaliC55, Error) << \"Failed to release input buffers\";\n+\t\tif (mem->cru_->freeBuffers())\n+\t\t\tLOG(MaliC55, Error) << \"Failed to release CRU buffers\";\n+\t}\n+\n \treturn;\n }\n \n@@ -1249,6 +1267,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@@ -1280,6 +1304,24 @@ int PipelineHandlerMaliC55::start(Camera *camera, [[maybe_unused]] const Control\n \tif (ret)\n \t\treturn ret;\n \n+\tif (auto *mem = std::get_if<MaliC55CameraData::Memory>(&data->input_)) {\n+\t\tret = mem->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@@ -1355,12 +1397,25 @@ int PipelineHandlerMaliC55::start(Camera *camera, [[maybe_unused]] const Control\n \treturn 0;\n }\n \n+void PipelineHandlerMaliC55::cancelPendingRequests()\n+{\n+\twhile (!pendingRequests_.empty()) {\n+\t\tcancelRequest(pendingRequests_.front());\n+\t\tpendingRequests_.pop();\n+\t}\n+}\n+\n void PipelineHandlerMaliC55::stopDevice(Camera *camera)\n {\n \tMaliC55CameraData *data = cameraData(camera);\n \n \tisp_->setFrameStartEnabled(false);\n \n+\tif (auto *mem = std::get_if<MaliC55CameraData::Memory>(&data->input_)) {\n+\t\tivc_->streamOff();\n+\t\tmem->cru_->stop();\n+\t}\n+\n \tfor (MaliC55Pipe &pipe : pipes_) {\n \t\tif (!pipe.stream)\n \t\t\tcontinue;\n@@ -1374,6 +1429,8 @@ void PipelineHandlerMaliC55::stopDevice(Camera *camera)\n \tif (data->ipa_)\n \t\tdata->ipa_->stop();\n \tfreeBuffers(camera);\n+\n+\tcancelPendingRequests();\n }\n \n void PipelineHandlerMaliC55::applyScalerCrop(Camera *camera,\n@@ -1472,10 +1529,85 @@ void PipelineHandlerMaliC55::applyScalerCrop(Camera *camera,\n \t}\n }\n \n+MaliC55FrameInfo *\n+PipelineHandlerMaliC55::prepareFrameInfo(Request *request, RZG2LCRU *cru)\n+{\n+\tif (availableStatsBuffers_.empty()) {\n+\t\tLOG(MaliC55, Error) << \"Stats buffer underrun\";\n+\t\treturn nullptr;\n+\t}\n+\n+\tif (availableParamsBuffers_.empty()) {\n+\t\tLOG(MaliC55, Error) << \"Params buffer underrun\";\n+\t\treturn nullptr;\n+\t}\n+\n+\tMaliC55FrameInfo &frameInfo = frameInfoMap_[request->sequence()];\n+\tframeInfo.request = request;\n+\n+\tif (cru) {\n+\t\tframeInfo.rawBuffer = cru->queueBuffer(request);\n+\t\tif (!frameInfo.rawBuffer)\n+\t\t\treturn nullptr;\n+\t}\n+\n+\tframeInfo.statBuffer = availableStatsBuffers_.front();\n+\tavailableStatsBuffers_.pop();\n+\tframeInfo.paramBuffer = availableParamsBuffers_.front();\n+\tavailableParamsBuffers_.pop();\n+\n+\tframeInfo.paramsDone = false;\n+\tframeInfo.statsDone = false;\n+\n+\treturn &frameInfo;\n+}\n+\n+int PipelineHandlerMaliC55::queuePendingRequests(MaliC55CameraData *data)\n+{\n+\tauto *mem = std::get_if<MaliC55CameraData::Memory>(&data->input_);\n+\tASSERT(mem);\n+\n+\twhile (!pendingRequests_.empty()) {\n+\t\tRequest *request = pendingRequests_.front();\n+\n+\t\tif (!prepareFrameInfo(request, mem->cru_.get()))\n+\t\t\treturn -ENOENT;\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}\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@@ -1496,32 +1628,13 @@ int PipelineHandlerMaliC55::queueRequestDevice(Camera *camera, Request *request)\n \t\treturn 0;\n \t}\n \n-\tif (availableStatsBuffers_.empty()) {\n-\t\tLOG(MaliC55, Error) << \"Stats buffer underrun\";\n-\t\treturn -ENOENT;\n-\t}\n-\n-\tif (availableParamsBuffers_.empty()) {\n-\t\tLOG(MaliC55, Error) << \"Params buffer underrun\";\n+\tauto frameInfo = prepareFrameInfo(request);\n+\tif (!frameInfo)\n \t\treturn -ENOENT;\n-\t}\n-\n-\tMaliC55FrameInfo frameInfo;\n-\tframeInfo.request = request;\n-\n-\tframeInfo.statBuffer = availableStatsBuffers_.front();\n-\tavailableStatsBuffers_.pop();\n-\tframeInfo.paramBuffer = availableParamsBuffers_.front();\n-\tavailableParamsBuffers_.pop();\n-\n-\tframeInfo.paramsDone = false;\n-\tframeInfo.statsDone = false;\n-\n-\tframeInfoMap_[request->sequence()] = frameInfo;\n \n \tdata->ipa_->queueRequest(request->sequence(), request->controls());\n \tdata->ipa_->fillParams(request->sequence(),\n-\t\t\t       frameInfo.paramBuffer->cookie());\n+\t\t\t       frameInfo->paramBuffer->cookie());\n \n \treturn 0;\n }\n@@ -1540,18 +1653,21 @@ 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 \treturn nullptr;\n }\n \n-void PipelineHandlerMaliC55::tryComplete(MaliC55FrameInfo *info)\n+void PipelineHandlerMaliC55::tryComplete(MaliC55FrameInfo *info, bool cancelled)\n {\n-\tif (!info->paramsDone)\n-\t\treturn;\n-\tif (!info->statsDone)\n+\t/*\n+\t * If the buffer has been cancelled, we complete the request without\n+\t * waiting for the IPA.\n+\t */\n+\tif (!cancelled && (!info->paramsDone || !info->statsDone))\n \t\treturn;\n \n \tRequest *request = info->request;\n@@ -1575,13 +1691,15 @@ void PipelineHandlerMaliC55::imageBufferReady(FrameBuffer *buffer)\n \tASSERT(info);\n \n \tif (completeBuffer(request, buffer))\n-\t\ttryComplete(info);\n+\t\ttryComplete(info,\n+\t\t\t    buffer->metadata().status == FrameMetadata::FrameCancelled);\n }\n \n void PipelineHandlerMaliC55::paramsBufferReady(FrameBuffer *buffer)\n {\n \tMaliC55FrameInfo *info = findFrameInfo(buffer);\n-\tASSERT(info);\n+\tif (!info)\n+\t\treturn;\n \n \tinfo->paramsDone = true;\n \n@@ -1591,7 +1709,8 @@ void PipelineHandlerMaliC55::paramsBufferReady(FrameBuffer *buffer)\n void PipelineHandlerMaliC55::statsBufferReady(FrameBuffer *buffer)\n {\n \tMaliC55FrameInfo *info = findFrameInfo(buffer);\n-\tASSERT(info);\n+\tif (!info)\n+\t\treturn;\n \n \tRequest *request = info->request;\n \tMaliC55CameraData *data = cameraData(request->_d()->camera());\n@@ -1602,32 +1721,80 @@ void PipelineHandlerMaliC55::statsBufferReady(FrameBuffer *buffer)\n \t\t\t\t sensorControls);\n }\n \n+void PipelineHandlerMaliC55::cruBufferReady(FrameBuffer *buffer)\n+{\n+\t/*\n+\t * If the buffer has been cancelled, do not ask the IPA to prepare\n+\t * parameters.\n+\t *\n+\t * The Request this cancelled buffer belongs to will be handled by\n+\t * imageBufferReady() as we have queued buffers to the ISP capture\n+\t * devices at the same time we have queued this buffer to the CRU\n+\t * when running in m2m mode.\n+\t */\n+\tif (buffer->metadata().status == FrameMetadata::FrameCancelled)\n+\t\treturn;\n+\n+\tMaliC55FrameInfo *info = findFrameInfo(buffer);\n+\tASSERT(info);\n+\n+\tRequest *request = info->request;\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+\tauto it = frameInfoMap_.find(requestId);\n+\tif (it == frameInfoMap_.end())\n+\t\treturn;\n+\n+\tMaliC55FrameInfo &frameInfo = it->second;\n \tRequest *request = frameInfo.request;\n+\tif (!request)\n+\t\treturn;\n+\n \tMaliC55CameraData *data = cameraData(request->_d()->camera());\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} else {\n+\t\tivc_->queueBuffer(frameInfo.rawBuffer);\n+\t\tframeInfo.rawBuffer = nullptr;\n \t}\n }\n \n void PipelineHandlerMaliC55::statsProcessed(unsigned int requestId,\n \t\t\t\t\t    const ControlList &metadata)\n {\n-\tMaliC55FrameInfo &frameInfo = frameInfoMap_[requestId];\n+\tauto it = frameInfoMap_.find(requestId);\n+\tif (it == frameInfoMap_.end())\n+\t\treturn;\n+\n+\tMaliC55FrameInfo &frameInfo = it->second;\n+\tif (!frameInfo.request)\n+\t\treturn;\n \n \tframeInfo.statsDone = true;\n \tframeInfo.request->_d()->metadata().merge(metadata);\n@@ -1757,6 +1924,9 @@ bool PipelineHandlerMaliC55::registerMemoryInputCamera()\n \n \tivc_->bufferReady.connect(mem->cru_.get(), &RZG2LCRU::returnBuffer);\n \n+\tV4L2VideoDevice *cruOutput = mem->cru_->output();\n+\tcruOutput->bufferReady.connect(this, &PipelineHandlerMaliC55::cruBufferReady);\n+\n \treturn registerMaliCamera(std::move(data), sensor->device()->entity()->name());\n }\n \n","prefixes":["v6","6/7"]}