{"id":23927,"url":"https://patchwork.libcamera.org/api/patches/23927/?format=json","web_url":"https://patchwork.libcamera.org/patch/23927/","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":"<20250724065256.75175-11-dan.scally@ideasonboard.com>","date":"2025-07-24T06:52:56","name":"[10/10] libcamera: mali-c55: Match for memory input media entities","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"b96c106bd31ee2a4fbf0f6fa197f342c882f21f2","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/?format=json","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23927/mbox/","series":[{"id":5319,"url":"https://patchwork.libcamera.org/api/series/5319/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5319","date":"2025-07-24T06:52:46","name":"Support memory input mode in mali-c55","version":1,"mbox":"https://patchwork.libcamera.org/series/5319/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23927/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23927/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 B088EC332C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Jul 2025 06:53:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 962F06908C;\n\tThu, 24 Jul 2025 08:53:30 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D56E669085\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Jul 2025 08:53:16 +0200 (CEST)","from mail.ideasonboard.com\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0081017D1;\n\tThu, 24 Jul 2025 08:52:37 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"afxSiS23\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753339958;\n\tbh=WWatLoSknEiLUU87NIzW3oSNdF86COOhJbGRZ4QS3ss=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=afxSiS23b5MktkkN7maMhWAPE22cuHD7D/CmVCJjcLFEkPjy+8UT2F2wpIJYpD9EX\n\tzYes41mEqzwhX77FEkOjJaHHh2yroG7DcQScdJeVkRnYZ1znNbR3thY5vAyXADdKsa\n\t6JyRgCcqy6SpIVUq81+0+/g//p26qA9ZWPGmgW00=","From":"Daniel Scally <dan.scally@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Daniel Scally <dan.scally@ideasonboard.com>","Subject":"[PATCH 10/10] libcamera: mali-c55: Match for memory input media\n\tentities","Date":"Thu, 24 Jul 2025 07:52:56 +0100","Message-Id":"<20250724065256.75175-11-dan.scally@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20250724065256.75175-1-dan.scally@ideasonboard.com>","References":"<20250724065256.75175-1-dan.scally@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"Updating the Pipeline Handler's match() function to search for the\nentities necessary for memory input mode and create a CameraData\ninstance for that camera if one is found.\n\nSigned-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n---\n src/libcamera/pipeline/mali-c55/mali-c55.cpp | 100 ++++++++++++++++---\n 1 file changed, 85 insertions(+), 15 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\nindex 2a396950..e2f31e77 100644\n--- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n+++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n@@ -1817,6 +1817,45 @@ bool PipelineHandlerMaliC55::registerSensorCamera(MediaLink *ispLink)\n \treturn true;\n }\n \n+bool PipelineHandlerMaliC55::registerMemoryInputCamera()\n+{\n+\tMediaEntity *sensorEntity;\n+\tint ret;\n+\n+\tstd::unique_ptr<MaliC55CameraData> data = std::make_unique<MaliC55CameraData>(this);\n+\n+\tdata->cru_ = std::make_unique<RZG2LCRU>();\n+\tret = data->cru_->init(cruMedia_, &sensorEntity);\n+\tif (ret)\n+\t\treturn false;\n+\n+\tif (data->init(sensorEntity))\n+\t\treturn false;\n+\n+\tdata->cru_->setSensorAndCSI2Pointers(data->sensor_, data->csi_);\n+\n+\tdata->properties_ = data->sensor_->properties();\n+\n+\tconst CameraSensorProperties::SensorDelays &delays = data->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>(data->sensor_->device(),\n+\t\t\t\t\t\t  params);\n+\tisp_->frameStart.connect(data->delayedCtrls_.get(),\n+\t\t\t\t &DelayedControls::applyControls);\n+\tdata->cru_->output()->bufferReady.connect(this, &PipelineHandlerMaliC55::cruBufferReady);\n+\tinput_->bufferReady.connect(data->cru_.get(), &RZG2LCRU::cruReturnBuffer);\n+\n+\tif (!registerMaliCamera(std::move(data), sensorEntity->name()))\n+\t\treturn false;\n+\n+\treturn true;\n+}\n+\n bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n {\n \tconst MediaPad *ispSink;\n@@ -1826,14 +1865,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@@ -1893,6 +1932,22 @@ 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+\tDeviceMatch cru_dm(\"rzg2l_cru\");\n+\tcru_dm.add(std::regex(\"csi-[0-9a-f]{8}.csi2\"));\n+\tcru_dm.add(std::regex(\"cru-ip-[0-9a-f]{8}.cru[0-9]\"));\n+\tcru_dm.add(\"CRU output\");\n+\tcruMedia_ = acquireMediaDevice(enumerator, cru_dm);\n+\n \tispSink = isp_->entity()->getPadByIndex(0);\n \tif (!ispSink || ispSink->links().empty()) {\n \t\tLOG(MaliC55, Error) << \"ISP sink pad error\";\n@@ -1907,12 +1962,13 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\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 * The TPG is relatively easy, we just register a Camera for it. If we\n+\t * have a CSI-2 receiver we need to check its sink pad and register\n+\t * Cameras for anything connected to it (probably...there are some\n+\t * complex situations in which that might not be true but let's pretend\n+\t * they don't exist until we come across them). If we have an input\n+\t * device then we need to acquire the V4L2 infrastructure for it and\n+\t * confirm that we found the rzg2l-cru media device too.\n \t */\n \tbool registered;\n \tfor (MediaLink *link : ispSink->links()) {\n@@ -1932,7 +1988,21 @@ 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\tivc_ = V4L2Subdevice::fromEntityName(media_, \"rzv2h ivc block\");\n+\t\t\tif (ivc_->open() < 0)\n+\t\t\t\treturn false;\n+\n+\t\t\tinput_ = V4L2VideoDevice::fromEntityName(media_, \"rzv2h-ivc\");\n+\t\t\tif (input_->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":["10/10"]}