{"id":26338,"url":"https://patchwork.libcamera.org/api/patches/26338/?format=json","web_url":"https://patchwork.libcamera.org/patch/26338/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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-4-b16b0c49819a@ideasonboard.com>","date":"2026-03-25T14:44:11","name":"[v6,4/7] libcamera: mali-c55: Register memory input camera","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"625f3ac557db4bd87b9c41c3bc3589bcbb814bac","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26338/mbox/","series":[{"id":5848,"url":"https://patchwork.libcamera.org/api/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/26338/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26338/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 7FECDC32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Mar 2026 14:44:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2732C627D7;\n\tWed, 25 Mar 2026 15:44:25 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1046B627A8\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 16737121A;\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=\"aMq3hSwF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1774449782;\n\tbh=Ojnmz9x+DXQFBfVhMAnLOJ9jhNzcj66e63HUZdvKwDE=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=aMq3hSwF67pR9nUtnBIuUz9AG0kYjfLVP3jL2wYX1B4Z6+Bj+tN1/twThILMGKslp\n\teF4yZELIG3a6Cd33reVLAjFauvi22NzFBn1mYI98qVXsaSiWWKDRWheCKsQIYrywtO\n\tbo2fau20dwVwdAL+0/Bh3pEmdWJxfB73ZeYPpnHE=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Wed, 25 Mar 2026 15:44:11 +0100","Subject":"[PATCH v6 4/7] libcamera: mali-c55: Register memory input camera","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20260325-mali-cru-v6-4-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=9308;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=Ojnmz9x+DXQFBfVhMAnLOJ9jhNzcj66e63HUZdvKwDE=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpw/TB7WTWMWTC/9Y4tc/+gf+xzA6XEuWdyMERD\n\tBk+cLYd6WOJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCacP0wQAKCRByNAaPFqFW\n\tPFASD/4qi6WEF6a4y9mkSoJssTRGtxsifPPwTXr/CYIVcRD4f4CXZNDgqbx0IPy6I4pU1P2lvj7\n\tVF0C3CpvR/qCi2Pj6dyL3/Q61PIMWfO9OUGBVfelcPX4EnfBa97nhyy2Qu9KN2QiYcxquD1cKGA\n\tXSgWTgdfQd94BhBSmW9hiFG5eQF/gHveAjMSNFICblUToD7nr3Mf6GPjE3xrXGQO29qxkHK7jq1\n\t3jfgDxpb/Dud0tzpqH1FWsQw6dkq6LtcxoZmMHAyIW1Nx5+KRZO667h/EtrcBR5NgYDr+0kMPX8\n\tKHiYtKpmkp+zAaOb/ulv5x53O2qY6PmpyvgYkiHaK8Y4gISj9tMB2LDjzZTa1n65K7UkqRJt8H4\n\tgGYkimduLihhp3uZMOX5TpzLeee6z97If8tjInDpLCjFffwz1j5xqk6XfJ61RUijCHV2W1EuM1a\n\toqvpaOu1K4YpVWNNKRvytQ8cHaeS8DFl4fCRe3bY2dk6feIWel41nYJL9hbI5xxwh5s5DvIy1/Z\n\tLqkLgHO5eB44CS/IIhZ3Na3wAtOVe66bUjmNvxEJrN9zxLLxWhFfWDYHHzdwhiBScO+X9K8SyU1\n\tUJbIQIasFATz6gyzuxNival98NWvMnFPxfWZhIKEJFClUtmCJkI7b4zOqqywp2nTNv297taL5aJ\n\t9gNwjJPxKF8fRnQ==","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":"Add support to Mali C55 pipeline handler for memory-to-memory camera\nmode.\n\nThe Mali-C55, as integrated in the Renesas RZ/V2H(P) SoC, is fed with\nimages saved to memory by the CRU unit and read on behalf of the ISP\nby the IVC.\n\nUpdate the pipeline handler's match() function to search for the CRU\nmedia entity necessary to register a memory input camera. Create and\ninitialize a CameraData instance for the memory camera use case if a\nvalid CRU is found and initialize the IVC components used to feed the\nISP with images read from memory.\n\nDo not implement camera configuration for the time being to reuce\nthe patch size. It will be provided in the following patches.\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 | 135 +++++++++++++++++++++++----\n 1 file changed, 117 insertions(+), 18 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\nindex dca82564e2eb..26d368bb9132 100644\n--- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n+++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n@@ -44,6 +44,8 @@\n #include \"libcamera/internal/v4l2_subdevice.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n \n+#include \"rzg2l-cru.h\"\n+\n namespace {\n \n bool isFormatRaw(const libcamera::PixelFormat &pixFmt)\n@@ -105,7 +107,12 @@ public:\n \t\tstd::unique_ptr<V4L2Subdevice> csi2_;\n \t\tstd::unique_ptr<CameraSensor> sensor_;\n \t};\n-\tusing CameraType = std::variant<Tpg, Inline>;\n+\n+\tstruct Memory {\n+\t\tstd::unique_ptr<RZG2LCRU> cru_;\n+\t};\n+\n+\tusing CameraType = std::variant<Tpg, Inline, Memory>;\n \n \tMaliC55CameraData(PipelineHandler *pipe)\n \t\t: Camera::Private(pipe)\n@@ -116,6 +123,7 @@ public:\n \n \tTpg *initTpg(MediaEntity *entity);\n \tInline *initInline(MediaEntity *entity);\n+\tMemory *initMemory(MediaDevice *cruMedia);\n \n \tstd::vector<Size> sizes(unsigned int mbusCode) const\n \t{\n@@ -125,7 +133,10 @@ public:\n \t\t\t},\n \t\t\t[&](const Inline &in) -> std::vector<Size> {\n \t\t\t\treturn in.sensor_->sizes(mbusCode);\n-\t\t\t}\n+\t\t\t},\n+\t\t\t[&](const Memory &mem) -> std::vector<Size> {\n+\t\t\t\treturn mem.cru_->sizes();\n+\t\t\t},\n \t\t}, input_);\n \t}\n \n@@ -138,6 +149,9 @@ public:\n \t\t\t[&](const Inline &in) -> V4L2Subdevice * {\n \t\t\t\treturn in.sensor_->device();\n \t\t\t},\n+\t\t\t[&](const Memory &mem) -> V4L2Subdevice * {\n+\t\t\t\treturn mem.cru_->sensor()->device();\n+\t\t\t},\n \t\t}, input_);\n \t}\n \n@@ -151,6 +165,9 @@ public:\n \t\t\t[&](const Inline &in) -> CameraSensor * {\n \t\t\t\treturn in.sensor_.get();\n \t\t\t},\n+\t\t\t[&](const Memory &mem) -> CameraSensor * {\n+\t\t\t\treturn mem.cru_->sensor();\n+\t\t\t},\n \t\t}, input_);\n \t}\n \n@@ -163,6 +180,9 @@ public:\n \t\t\t[&](const Inline &in) -> Size {\n \t\t\t\treturn in.sensor_->resolution();\n \t\t\t},\n+\t\t\t[&](const Memory &mem) -> Size {\n+\t\t\t\treturn mem.cru_->resolution();\n+\t\t\t},\n \t\t}, input_);\n \t}\n \n@@ -241,6 +261,19 @@ MaliC55CameraData::Inline *MaliC55CameraData::initInline(MediaEntity *sensor)\n \treturn &input_.emplace<Inline>(std::move(in));\n }\n \n+MaliC55CameraData::Memory *MaliC55CameraData::initMemory(MediaDevice *cruMedia)\n+{\n+\tMemory mem;\n+\n+\tmem.cru_ = std::make_unique<RZG2LCRU>();\n+\n+\tint ret = mem.cru_->init(cruMedia);\n+\tif (ret)\n+\t\treturn nullptr;\n+\n+\treturn &input_.emplace<Memory>(std::move(mem));\n+}\n+\n std::vector<Size> MaliC55CameraData::Tpg::sizes(unsigned int mbusCode) const\n {\n \tV4L2Subdevice::Formats formats = sd_->formats(0);\n@@ -721,11 +754,15 @@ private:\n \t\t\t\tconst std::string &name);\n \tbool registerTPGCamera(MediaLink *link);\n \tbool registerSensorCamera(MediaLink *link);\n+\tbool registerMemoryInputCamera();\n \n \tstd::shared_ptr<MediaDevice> media_;\n+\tstd::shared_ptr<MediaDevice> cruMedia_;\n \tstd::unique_ptr<V4L2Subdevice> isp_;\n \tstd::unique_ptr<V4L2VideoDevice> stats_;\n \tstd::unique_ptr<V4L2VideoDevice> params_;\n+\tstd::unique_ptr<V4L2Subdevice> ivcSd_;\n+\tstd::unique_ptr<V4L2VideoDevice> ivc_;\n \n \tstd::vector<std::unique_ptr<FrameBuffer>> statsBuffers_;\n \tstd::queue<FrameBuffer *> availableStatsBuffers_;\n@@ -976,6 +1013,9 @@ int PipelineHandlerMaliC55::configure(Camera *camera,\n \t\t\tconst MediaEntity *csi2Entity = in.csi2_->entity();\n \t\t\treturn csi2Entity->getPadByIndex(1)->links()[0]->setEnabled(true);\n \t\t},\n+\t\t[](MaliC55CameraData::Memory &) {\n+\t\t\treturn 0;\n+\t\t},\n \t}, data->input_);\n \tif (ret)\n \t\treturn ret;\n@@ -1001,6 +1041,9 @@ int PipelineHandlerMaliC55::configure(Camera *camera,\n \n \t\t\treturn in.csi2_->getFormat(1, &subdevFormat);\n \t\t},\n+\t\t[](MaliC55CameraData::Memory &) {\n+\t\t\treturn 0;\n+\t\t},\n \t}, data->input_);\n \tif (ret)\n \t\treturn ret;\n@@ -1673,6 +1716,34 @@ bool PipelineHandlerMaliC55::registerSensorCamera(MediaLink *ispLink)\n \treturn true;\n }\n \n+bool PipelineHandlerMaliC55::registerMemoryInputCamera()\n+{\n+\tstd::unique_ptr<MaliC55CameraData> data =\n+\t\tstd::make_unique<MaliC55CameraData>(this);\n+\n+\tauto *mem = data->initMemory(cruMedia_.get());\n+\tif (!mem)\n+\t\treturn false;\n+\n+\tCameraSensor *sensor = data->sensor();\n+\tdata->properties_ = sensor->properties();\n+\n+\tconst CameraSensorProperties::SensorDelays &delays = sensor->sensorDelays();\n+\tstd::unordered_map<uint32_t, DelayedControls::ControlParams> params = {\n+\t\t{ V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } },\n+\t\t{ V4L2_CID_EXPOSURE, { delays.exposureDelay, false } },\n+\t};\n+\n+\tdata->delayedCtrls_ =\n+\t\tstd::make_unique<DelayedControls>(sensor->device(), params);\n+\tisp_->frameStart.connect(data->delayedCtrls_.get(),\n+\t\t\t\t &DelayedControls::applyControls);\n+\n+\tivc_->bufferReady.connect(mem->cru_.get(), &RZG2LCRU::returnBuffer);\n+\n+\treturn registerMaliCamera(std::move(data), sensor->device()->entity()->name());\n+}\n+\n bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n {\n \tconst MediaPad *ispSink;\n@@ -1682,14 +1753,14 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n \t * The TPG and the downscale pipe are both optional blocks and may not\n \t * be fitted.\n \t */\n-\tDeviceMatch dm(\"mali-c55\");\n-\tdm.add(\"mali-c55 isp\");\n-\tdm.add(\"mali-c55 resizer fr\");\n-\tdm.add(\"mali-c55 fr\");\n-\tdm.add(\"mali-c55 3a stats\");\n-\tdm.add(\"mali-c55 3a params\");\n-\n-\tmedia_ = acquireMediaDevice(enumerator, dm);\n+\tDeviceMatch c55_dm(\"mali-c55\");\n+\tc55_dm.add(\"mali-c55 isp\");\n+\tc55_dm.add(\"mali-c55 resizer fr\");\n+\tc55_dm.add(\"mali-c55 fr\");\n+\tc55_dm.add(\"mali-c55 3a stats\");\n+\tc55_dm.add(\"mali-c55 3a params\");\n+\n+\tmedia_ = acquireMediaDevice(enumerator, c55_dm);\n \tif (!media_)\n \t\treturn false;\n \n@@ -1749,6 +1820,25 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n \tstats_->bufferReady.connect(this, &PipelineHandlerMaliC55::statsBufferReady);\n \tparams_->bufferReady.connect(this, &PipelineHandlerMaliC55::paramsBufferReady);\n \n+\t/*\n+\t * We also need to search for the rzg2l-cru CSI-2 receiver. If we find\n+\t * that then we need to work in memory input mode instead of the inline\n+\t * mode. The absence of this match is not necessarily a failure at this\n+\t * point...it depends on the media links that we investigate momentarily.\n+\t *\n+\t * This is a bit hacky, because there could be multiple of these media\n+\t * devices and we're just taking the first. We need modular pipelines to\n+\t * properly solve the issue.\n+\t */\n+\tstatic const std::regex cruCsi2Regex(\"csi-[0-9a-f]{8}.csi2\");\n+\tstatic const std::regex cruIpRegex(\"cru-ip-[0-9a-f]{8}.cru[0-9]\");\n+\n+\tDeviceMatch cruDm(\"rzg2l_cru\");\n+\tcruDm.add(cruCsi2Regex);\n+\tcruDm.add(cruIpRegex);\n+\tcruDm.add(\"CRU output\");\n+\tcruMedia_ = acquireMediaDevice(enumerator, cruDm);\n+\n \tispSink = isp_->entity()->getPadByIndex(0);\n \tif (!ispSink || ispSink->links().empty()) {\n \t\tLOG(MaliC55, Error) << \"ISP sink pad error\";\n@@ -1762,13 +1852,6 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n \t * MEDIA_ENT_F_CAM_SENSOR - The test pattern generator\n \t * MEDIA_ENT_F_VID_IF_BRIDGE - A CSI-2 receiver\n \t * MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER - An input device\n-\t *\n-\t * The last one will be unsupported for now. The TPG is relatively easy,\n-\t * we just register a Camera for it. If we have a CSI-2 receiver we need\n-\t * to check its sink pad and register Cameras for anything connected to\n-\t * it (probably...there are some complex situations in which that might\n-\t * not be true but let's pretend they don't exist until we come across\n-\t * them)\n \t */\n \tbool registered;\n \tfor (MediaLink *link : ispSink->links()) {\n@@ -1788,7 +1871,23 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n \n \t\t\tbreak;\n \t\tcase MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER:\n-\t\t\tLOG(MaliC55, Warning) << \"Memory input not yet supported\";\n+\t\t\tif (!cruMedia_)\n+\t\t\t\treturn false;\n+\n+\t\t\tivcSd_ = V4L2Subdevice::fromEntityName(media_.get(),\n+\t\t\t\t\t\t\t       \"rzv2h ivc block\");\n+\t\t\tif (ivcSd_->open() < 0)\n+\t\t\t\treturn false;\n+\n+\t\t\tivc_ = V4L2VideoDevice::fromEntityName(media_.get(),\n+\t\t\t\t\t\t\t       \"rzv2h-ivc\");\n+\t\t\tif (ivc_->open() < 0)\n+\t\t\t\treturn false;\n+\n+\t\t\tregistered = registerMemoryInputCamera();\n+\t\t\tif (!registered)\n+\t\t\t\treturn registered;\n+\n \t\t\tbreak;\n \t\tdefault:\n \t\t\tLOG(MaliC55, Error) << \"Unsupported entity function\";\n","prefixes":["v6","4/7"]}