[{"id":35085,"web_url":"https://patchwork.libcamera.org/comment/35085/","msgid":"<175334722082.560048.4777969381691390900@ping.linuxembedded.co.uk>","date":"2025-07-24T08:53:40","subject":"Re: [PATCH 10/10] libcamera: mali-c55: Match for memory input media\n\tentities","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Daniel Scally (2025-07-24 07:52:56)\n> Updating the Pipeline Handler's match() function to search for the\n> entities necessary for memory input mode and create a CameraData\n> instance for that camera if one is found.\n> \n> Signed-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(-)\n> \n> diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n> index 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>         return true;\n>  }\n>  \n> +bool PipelineHandlerMaliC55::registerMemoryInputCamera()\n> +{\n> +       MediaEntity *sensorEntity;\n> +       int ret;\n> +\n> +       std::unique_ptr<MaliC55CameraData> data = std::make_unique<MaliC55CameraData>(this);\n> +\n> +       data->cru_ = std::make_unique<RZG2LCRU>();\n> +       ret = data->cru_->init(cruMedia_, &sensorEntity);\n> +       if (ret)\n> +               return false;\n> +\n> +       if (data->init(sensorEntity))\n> +               return false;\n> +\n> +       data->cru_->setSensorAndCSI2Pointers(data->sensor_, data->csi_);\n> +\n> +       data->properties_ = data->sensor_->properties();\n> +\n> +       const CameraSensorProperties::SensorDelays &delays = data->sensor_->sensorDelays();\n> +       std::unordered_map<uint32_t, DelayedControls::ControlParams> params = {\n> +               { V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } },\n> +               { V4L2_CID_EXPOSURE, { delays.exposureDelay, false } },\n> +       };\n> +\n> +       data->delayedCtrls_ =\n> +               std::make_unique<DelayedControls>(data->sensor_->device(),\n> +                                                 params);\n> +       isp_->frameStart.connect(data->delayedCtrls_.get(),\n> +                                &DelayedControls::applyControls);\n> +       data->cru_->output()->bufferReady.connect(this, &PipelineHandlerMaliC55::cruBufferReady);\n> +       input_->bufferReady.connect(data->cru_.get(), &RZG2LCRU::cruReturnBuffer);\n> +\n> +       if (!registerMaliCamera(std::move(data), sensorEntity->name()))\n> +               return false;\n> +\n> +       return true;\n> +}\n> +\n>  bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n>  {\n>         const MediaPad *ispSink;\n> @@ -1826,14 +1865,14 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n>          * The TPG and the downscale pipe are both optional blocks and may not\n>          * be fitted.\n>          */\n> -       DeviceMatch dm(\"mali-c55\");\n> -       dm.add(\"mali-c55 isp\");\n> -       dm.add(\"mali-c55 resizer fr\");\n> -       dm.add(\"mali-c55 fr\");\n> -       dm.add(\"mali-c55 3a stats\");\n> -       dm.add(\"mali-c55 3a params\");\n> -\n> -       media_ = acquireMediaDevice(enumerator, dm);\n> +       DeviceMatch c55_dm(\"mali-c55\");\n> +       c55_dm.add(\"mali-c55 isp\");\n> +       c55_dm.add(\"mali-c55 resizer fr\");\n> +       c55_dm.add(\"mali-c55 fr\");\n> +       c55_dm.add(\"mali-c55 3a stats\");\n> +       c55_dm.add(\"mali-c55 3a params\");\n> +\n> +       media_ = acquireMediaDevice(enumerator, c55_dm);\n>         if (!media_)\n>                 return false;\n>  \n> @@ -1893,6 +1932,22 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n>         stats_->bufferReady.connect(this, &PipelineHandlerMaliC55::statsBufferReady);\n>         params_->bufferReady.connect(this, &PipelineHandlerMaliC55::paramsBufferReady);\n>  \n> +       /*\n> +        * We also need to search for the rzg2l-cru CSI-2 receiver. If we find\n> +        * that then we need to work in memory input mode instead of the inline\n> +        * mode. The absence of this match is not necessarily a failure at this\n> +        * point...it depends on the media links that we investigate momentarily.\n> +        *\n> +        * This is a bit hacky, because there could be multiple of these media\n> +        * devices and we're just taking the first. We need modular pipelines to\n> +        * properly solve the issue.\n> +        */\n\nInteresting - I'd almost switch it around sometime - as the CRU is what's going\nto define the existing of actual cameras. So if we find a CRU - then we\nfind a suitable C55 memory input device and construct a pipeline from\nthat.\n\nThen we construct independent C55 pipelines from whatevers left (which\npresumably would be only the inline operational versions - even if there\nwas a hypothetical system with both combinations...)\n\n\nI guess that's how we move to modular pipelines too \"First find media\ndevices that can support sensors, then find compatible ISPs (including\nSoft/GPU) to pair up to the camera devices and register the pipeline\"\n(but yes - that's later).\n\n\n> +       DeviceMatch cru_dm(\"rzg2l_cru\");\n> +       cru_dm.add(std::regex(\"csi-[0-9a-f]{8}.csi2\"));\n> +       cru_dm.add(std::regex(\"cru-ip-[0-9a-f]{8}.cru[0-9]\"));\n> +       cru_dm.add(\"CRU output\");\n> +       cruMedia_ = acquireMediaDevice(enumerator, cru_dm);\n> +\n>         ispSink = isp_->entity()->getPadByIndex(0);\n>         if (!ispSink || ispSink->links().empty()) {\n>                 LOG(MaliC55, Error) << \"ISP sink pad error\";\n> @@ -1907,12 +1962,13 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n>          * MEDIA_ENT_F_VID_IF_BRIDGE - A CSI-2 receiver\n>          * MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER - An input device\n>          *\n> -        * The last one will be unsupported for now. The TPG is relatively easy,\n> -        * we just register a Camera for it. If we have a CSI-2 receiver we need\n> -        * to check its sink pad and register Cameras for anything connected to\n> -        * it (probably...there are some complex situations in which that might\n> -        * not be true but let's pretend they don't exist until we come across\n> -        * them)\n> +        * The TPG is relatively easy, we just register a Camera for it. If we\n> +        * have a CSI-2 receiver we need to check its sink pad and register\n> +        * Cameras for anything connected to it (probably...there are some\n> +        * complex situations in which that might not be true but let's pretend\n> +        * they don't exist until we come across them). If we have an input\n> +        * device then we need to acquire the V4L2 infrastructure for it and\n> +        * confirm that we found the rzg2l-cru media device too.\n>          */\n>         bool registered;\n>         for (MediaLink *link : ispSink->links()) {\n> @@ -1932,7 +1988,21 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator)\n>  \n>                         break;\n>                 case MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER:\n> -                       LOG(MaliC55, Warning) << \"Memory input not yet supported\";\n> +                       if (!cruMedia_)\n> +                               return false;\n> +\n> +                       ivc_ = V4L2Subdevice::fromEntityName(media_, \"rzv2h ivc block\");\n> +                       if (ivc_->open() < 0)\n> +                               return false;\n> +\n> +                       input_ = V4L2VideoDevice::fromEntityName(media_, \"rzv2h-ivc\");\n> +                       if (input_->open() < 0)\n> +                               return false;\n> +\n> +                       registered = registerMemoryInputCamera();\n> +                       if (!registered)\n> +                               return registered;\n> +\n>                         break;\n>                 default:\n>                         LOG(MaliC55, Error) << \"Unsupported entity function\";\n> -- \n> 2.30.2\n>","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 AD64BC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Jul 2025 08:53:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D131D690C1;\n\tThu, 24 Jul 2025 10:53:44 +0200 (CEST)","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 B301F690BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Jul 2025 10:53:43 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B69AAC79;\n\tThu, 24 Jul 2025 10:53:04 +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=\"ivYVvLjb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753347184;\n\tbh=+kxjZZCYGg4/vf5L8X8A4BB9glKQuSPExk/X4SdWvQ0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ivYVvLjbEEeY5RV+Z38/zlTvuHarnKkCpYAIDrtos7+mnCrxGNMO9g3iYSg8tZNfb\n\t9f8Z5rZmAMzOXb92TaRhfIDWldiWUNyW2hbM8J9o70bas2jOfA/25xiIpJNTNrkmSX\n\tgoXF0zEhHJ0m1n5LPNmP13gIjMZWULGy5BwrjBLA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250724065256.75175-11-dan.scally@ideasonboard.com>","References":"<20250724065256.75175-1-dan.scally@ideasonboard.com>\n\t<20250724065256.75175-11-dan.scally@ideasonboard.com>","Subject":"Re: [PATCH 10/10] libcamera: mali-c55: Match for memory input media\n\tentities","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Daniel Scally <dan.scally@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 24 Jul 2025 09:53:40 +0100","Message-ID":"<175334722082.560048.4777969381691390900@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]