[{"id":38463,"web_url":"https://patchwork.libcamera.org/comment/38463/","msgid":"<e6787a13-bbe6-454c-ada5-94588836d24e@ideasonboard.com>","date":"2026-03-31T13:48:51","subject":"Re: [PATCH v6 3/7] libcamera: mali-c55: Split TPG and Inline camera\n\thandling","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 03. 25. 15:44 keltezéssel, Jacopo Mondi írta:\n> In order to prepare to support memory input cameras, split the handling of\n> the TPG and Inline camera cases.\n> \n> The Mali C55 pipeline handler uses the entity and subdevice stored in the\n> CameraData to support both the handling of the TPG and of the Inline (CSI-2\n> + sensor) use cases. Adding support for memory cameras by using the CRU unit\n> would add yet-another special case making the code harder to follow and\n> more prone to errors.\n> \n> Split the handling of the TPG and Inline cameras by introducing an\n> std::variant<> variable and to deflect the functions called on the\n> camera data to the correct type by using overloaded std::visit<>().\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> ---\n>   src/libcamera/pipeline/mali-c55/mali-c55.cpp | 278 ++++++++++++++++-----------\n>   1 file changed, 162 insertions(+), 116 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 c209b0b070b1..dca82564e2eb 100644\n> --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n> +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n> [...]\n> @@ -927,39 +967,44 @@ int PipelineHandlerMaliC55::configure(Camera *camera,\n>   \n>   \t/* Link the graph depending if we are operating the TPG or a sensor. */\n>   \tMaliC55CameraData *data = cameraData(camera);\n> -\tif (data->csi_) {\n> -\t\tconst MediaEntity *csiEntity = data->csi_->entity();\n> -\t\tret = csiEntity->getPadByIndex(1)->links()[0]->setEnabled(true);\n> -\t} else {\n> -\t\tret = data->entity_->getPadByIndex(0)->links()[0]->setEnabled(true);\n> -\t}\n> +\tret = std::visit(utils::overloaded{\n> +\t\t[](MaliC55CameraData::Tpg &tpg) {\n> +\t\t\tconst MediaEntity *tpgEntity = tpg.sd_->entity();\n> +\t\t\treturn tpgEntity->getPadByIndex(0)->links()[0]->setEnabled(true);\n> +\t\t},\n> +\t\t[](MaliC55CameraData::Inline &in) {\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}, data->input_);\n>   \tif (ret)\n>   \t\treturn ret;\n>   \n>   \tMaliC55CameraConfiguration *maliConfig =\n>   \t\tstatic_cast<MaliC55CameraConfiguration *>(config);\n>   \tV4L2SubdeviceFormat subdevFormat = maliConfig->sensorFormat_;\n> -\tret = data->sd_->getFormat(0, &subdevFormat);\n> +\n> +\t/* Apply format to the origin of the pipeline and propagate it. */\n> +\tret = std::visit(utils::overloaded{\n> +\t\t[&](MaliC55CameraData::Tpg &) {\n\n   MaliC55CameraData::Tpg &tpg\n\n> +\t\t\treturn data->subdev()->setFormat(0, &subdevFormat);\n\n   return tpg.sd_->setFormat(0, &subdevFormat);\n\n\n> +\t\t},\n> +\t\t[&](MaliC55CameraData::Inline &in) {\n> +\t\t\tint r = in.sensor_->setFormat(&subdevFormat,\n> +\t\t\t\t\t\t      maliConfig->combinedTransform());\n> +\t\t\tif (r)\n> +\t\t\t\treturn r;\n> +\n> +\t\t\tr = in.csi2_->setFormat(0, &subdevFormat);\n> +\t\t\tif (r)\n> +\t\t\t\treturn r;\n> +\n> +\t\t\treturn in.csi2_->getFormat(1, &subdevFormat);\n> +\t\t},\n> +\t}, data->input_);\n>   \tif (ret)\n>   \t\treturn ret;\n>   \n> -\tif (data->sensor_) {\n> -\t\tret = data->sensor_->setFormat(&subdevFormat,\n> -\t\t\t\t\t       maliConfig->combinedTransform());\n> -\t\tif (ret)\n> -\t\t\treturn ret;\n> -\t}\n> -\n> -\tif (data->csi_) {\n> -\t\tret = data->csi_->setFormat(0, &subdevFormat);\n> -\t\tif (ret)\n> -\t\t\treturn ret;\n> -\n> -\t\tret = data->csi_->getFormat(1, &subdevFormat);\n> -\t\tif (ret)\n> -\t\t\treturn ret;\n> -\t}\n> -\n>   \tV4L2DeviceFormat statsFormat;\n>   \tret = stats_->getFormat(&statsFormat);\n>   \tif (ret)\n> [...]\n\nThe conversion looks ok to me, but unfortunately I can't test it at all.\nNo inline mode compatible device, and the TPG for some reason does not work,\nnot sure if it's a kernel or libcamera issue.\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>","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 92EE7BEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 31 Mar 2026 13:48:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3CD9F62D0F;\n\tTue, 31 Mar 2026 15:48:55 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B7C56274D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 31 Mar 2026 15:48:54 +0200 (CEST)","from [192.168.33.35] (185.221.143.129.nat.pool.zt.hu\n\t[185.221.143.129])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E4651143C;\n\tTue, 31 Mar 2026 15:47:31 +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=\"ZAkYzTZ3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1774964852;\n\tbh=HhSTRGg/bB47kKPMPliotB0q3JoWMMw0HZAZHZVy9Fw=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=ZAkYzTZ34L2BfqjqH7IFWrJhw0xPU7fyJLpFrxs+8rlUsGrD5E/6vAlWy9C6R98nJ\n\tPJr1sql17T0IXMpYS0OcMZxO1GfSMgD+cKSts+hMqzkZUSdU8MT0yo6G36LBz0qMwr\n\ttZsdCRciwSHUFq7Abhx0y2nYo3jUkRgotSmV53Ls=","Message-ID":"<e6787a13-bbe6-454c-ada5-94588836d24e@ideasonboard.com>","Date":"Tue, 31 Mar 2026 15:48:51 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v6 3/7] libcamera: mali-c55: Split TPG and Inline camera\n\thandling","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260325-mali-cru-v6-0-b16b0c49819a@ideasonboard.com>\n\t<20260325-mali-cru-v6-3-b16b0c49819a@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260325-mali-cru-v6-3-b16b0c49819a@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}},{"id":38466,"web_url":"https://patchwork.libcamera.org/comment/38466/","msgid":"<acvo0J-rJbPONmm1@zed>","date":"2026-03-31T15:32:02","subject":"Re: [PATCH v6 3/7] libcamera: mali-c55: Split TPG and Inline camera\n\thandling","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Tue, Mar 31, 2026 at 03:48:51PM +0200, Barnabás Pőcze wrote:\n> 2026. 03. 25. 15:44 keltezéssel, Jacopo Mondi írta:\n> > In order to prepare to support memory input cameras, split the handling of\n> > the TPG and Inline camera cases.\n> >\n> > The Mali C55 pipeline handler uses the entity and subdevice stored in the\n> > CameraData to support both the handling of the TPG and of the Inline (CSI-2\n> > + sensor) use cases. Adding support for memory cameras by using the CRU unit\n> > would add yet-another special case making the code harder to follow and\n> > more prone to errors.\n> >\n> > Split the handling of the TPG and Inline cameras by introducing an\n> > std::variant<> variable and to deflect the functions called on the\n> > camera data to the correct type by using overloaded std::visit<>().\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> > ---\n> >   src/libcamera/pipeline/mali-c55/mali-c55.cpp | 278 ++++++++++++++++-----------\n> >   1 file changed, 162 insertions(+), 116 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 c209b0b070b1..dca82564e2eb 100644\n> > --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n> > +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n> > [...]\n> > @@ -927,39 +967,44 @@ int PipelineHandlerMaliC55::configure(Camera *camera,\n> >   \t/* Link the graph depending if we are operating the TPG or a sensor. */\n> >   \tMaliC55CameraData *data = cameraData(camera);\n> > -\tif (data->csi_) {\n> > -\t\tconst MediaEntity *csiEntity = data->csi_->entity();\n> > -\t\tret = csiEntity->getPadByIndex(1)->links()[0]->setEnabled(true);\n> > -\t} else {\n> > -\t\tret = data->entity_->getPadByIndex(0)->links()[0]->setEnabled(true);\n> > -\t}\n> > +\tret = std::visit(utils::overloaded{\n> > +\t\t[](MaliC55CameraData::Tpg &tpg) {\n> > +\t\t\tconst MediaEntity *tpgEntity = tpg.sd_->entity();\n> > +\t\t\treturn tpgEntity->getPadByIndex(0)->links()[0]->setEnabled(true);\n> > +\t\t},\n> > +\t\t[](MaliC55CameraData::Inline &in) {\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}, data->input_);\n> >   \tif (ret)\n> >   \t\treturn ret;\n> >   \tMaliC55CameraConfiguration *maliConfig =\n> >   \t\tstatic_cast<MaliC55CameraConfiguration *>(config);\n> >   \tV4L2SubdeviceFormat subdevFormat = maliConfig->sensorFormat_;\n> > -\tret = data->sd_->getFormat(0, &subdevFormat);\n> > +\n> > +\t/* Apply format to the origin of the pipeline and propagate it. */\n> > +\tret = std::visit(utils::overloaded{\n> > +\t\t[&](MaliC55CameraData::Tpg &) {\n>\n>   MaliC55CameraData::Tpg &tpg\n>\n> > +\t\t\treturn data->subdev()->setFormat(0, &subdevFormat);\n>\n>   return tpg.sd_->setFormat(0, &subdevFormat);\n>\n>\n> > +\t\t},\n> > +\t\t[&](MaliC55CameraData::Inline &in) {\n> > +\t\t\tint r = in.sensor_->setFormat(&subdevFormat,\n> > +\t\t\t\t\t\t      maliConfig->combinedTransform());\n> > +\t\t\tif (r)\n> > +\t\t\t\treturn r;\n> > +\n> > +\t\t\tr = in.csi2_->setFormat(0, &subdevFormat);\n> > +\t\t\tif (r)\n> > +\t\t\t\treturn r;\n> > +\n> > +\t\t\treturn in.csi2_->getFormat(1, &subdevFormat);\n> > +\t\t},\n> > +\t}, data->input_);\n> >   \tif (ret)\n> >   \t\treturn ret;\n> > -\tif (data->sensor_) {\n> > -\t\tret = data->sensor_->setFormat(&subdevFormat,\n> > -\t\t\t\t\t       maliConfig->combinedTransform());\n> > -\t\tif (ret)\n> > -\t\t\treturn ret;\n> > -\t}\n> > -\n> > -\tif (data->csi_) {\n> > -\t\tret = data->csi_->setFormat(0, &subdevFormat);\n> > -\t\tif (ret)\n> > -\t\t\treturn ret;\n> > -\n> > -\t\tret = data->csi_->getFormat(1, &subdevFormat);\n> > -\t\tif (ret)\n> > -\t\t\treturn ret;\n> > -\t}\n> > -\n> >   \tV4L2DeviceFormat statsFormat;\n> >   \tret = stats_->getFormat(&statsFormat);\n> >   \tif (ret)\n> > [...]\n>\n> The conversion looks ok to me, but unfortunately I can't test it at all.\n> No inline mode compatible device, and the TPG for some reason does not work,\n> not sure if it's a kernel or libcamera issue.\n\nSame here. If I'm not mistaken the TPG hangs before this series as\nwell, so at least we're not making things worse :)\n\n>\n> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\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 9C395BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 31 Mar 2026 15:32:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AC21C62D17;\n\tTue, 31 Mar 2026 17:32:06 +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 241246274D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 31 Mar 2026 17:32:05 +0200 (CEST)","from ideasonboard.com (net-93-65-100-155.cust.vodafonedsl.it\n\t[93.65.100.155])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 763B1244D;\n\tTue, 31 Mar 2026 17:30:42 +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=\"W+vL0ED7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1774971042;\n\tbh=h+i6G5NvcQTgYpOVTi16CB2EP/u4N3xBQkGVHsMjLxU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=W+vL0ED7gZ636YGa9ONRpJ4KesrRDANkS61wXOhevt4yw7+5sm9eWrpj6zqyTT9B2\n\t3DC71dG3gVmxeyXEvkBsvqHGxdoqCZD4lmsDbLdszpbsSATQsuOfODu0LOoP4rFA7B\n\tZ/m4CXiTS47oPK0j1pACR/7SUBVrXn1on26IRAEQ=","Date":"Tue, 31 Mar 2026 17:32:02 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, \n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v6 3/7] libcamera: mali-c55: Split TPG and Inline camera\n\thandling","Message-ID":"<acvo0J-rJbPONmm1@zed>","References":"<20260325-mali-cru-v6-0-b16b0c49819a@ideasonboard.com>\n\t<20260325-mali-cru-v6-3-b16b0c49819a@ideasonboard.com>\n\t<e6787a13-bbe6-454c-ada5-94588836d24e@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<e6787a13-bbe6-454c-ada5-94588836d24e@ideasonboard.com>","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>"}}]