[{"id":23859,"web_url":"https://patchwork.libcamera.org/comment/23859/","msgid":"<Ys7p2aewI4cxqo/I@pendragon.ideasonboard.com>","date":"2022-07-13T15:50:49","subject":"Re: [libcamera-devel] [PATCH v2] pipeline: rkisp1: Support media\n\tgraph with separate CSI RX","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Wed, Jul 13, 2022 at 08:34:43PM +0900, Paul Elder via libcamera-devel wrote:\n> The rkisp1 hardware supports both a CSI-2 input and a parallel input,\n> where the sensor is connected directly to the ISP. On RK3399, the CSI-2\n> receiver is internal, but on the i.MX8MP, the CSI-2 receiver is a\n> separate IP core, connected to the parallel input of the ISP, and gets\n> exposed to userspace as a V4L2 subdev. To prepare for this, handle an\n> optional CSI-2 receiver subdev in the pipeline.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> Changes in v2:\n> - clean up logic of determining pads/prescence of the CSI-2 receiver\n>   subdev\n> - upgrade the changelog\n> ---\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 42 ++++++++++++++++++++----\n>  1 file changed, 35 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 3dc0850c..2b0ead5d 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -178,6 +178,7 @@ private:\n>  \tstd::unique_ptr<V4L2Subdevice> isp_;\n>  \tstd::unique_ptr<V4L2VideoDevice> param_;\n>  \tstd::unique_ptr<V4L2VideoDevice> stat_;\n> +\tstd::unique_ptr<V4L2Subdevice> csi_;\n>  \n>  \tRkISP1MainPath mainPath_;\n>  \tRkISP1SelfPath selfPath_;\n> @@ -188,6 +189,8 @@ private:\n>  \tstd::queue<FrameBuffer *> availableStatBuffers_;\n>  \n>  \tCamera *activeCamera_;\n> +\n> +\tconst MediaPad *ispSink_;\n>  };\n>  \n>  RkISP1Frames::RkISP1Frames(PipelineHandler *pipe)\n> @@ -599,6 +602,12 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>  \n>  \tLOG(RkISP1, Debug) << \"Sensor configured with \" << format;\n>  \n> +\tif (csi_) {\n> +\t\tret = csi_->setFormat(0, &format);\n> +\t\tif (ret < 0)\n> +\t\t\treturn ret;\n> +\t}\n> +\n>  \tret = isp_->setFormat(0, &format);\n>  \tif (ret < 0)\n>  \t\treturn ret;\n> @@ -900,8 +909,7 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera,\n>  \t * Configure the sensor links: enable the link corresponding to this\n>  \t * camera.\n>  \t */\n> -\tconst MediaPad *pad = isp_->entity()->getPadByIndex(0);\n> -\tfor (MediaLink *link : pad->links()) {\n> +\tfor (MediaLink *link : ispSink_->links()) {\n>  \t\tif (link->source()->entity() != sensor->entity())\n>  \t\t\tcontinue;\n>  \n> @@ -915,6 +923,14 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera,\n>  \t\t\treturn ret;\n>  \t}\n>  \n> +\tif (csi_) {\n> +\t\tMediaLink *link = isp_->entity()->getPadByIndex(0)->links().at(0);\n> +\n> +\t\tret = link->setEnabled(true);\n> +\t\tif (ret < 0)\n> +\t\t\treturn ret;\n> +\t}\n> +\n>  \tfor (const StreamConfiguration &cfg : config) {\n>  \t\tif (cfg.stream() == &data->mainPathStream_)\n>  \t\t\tret = data->mainPath_->setEnabled(true);\n> @@ -1013,6 +1029,22 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n>  \tif (isp_->open() < 0)\n>  \t\treturn false;\n>  \n> +\t/* Locate and open the optional CSI-2 receiver. */\n> +\tispSink_ = isp_->entity()->getPadByIndex(0);\n> +\tif (!ispSink_ || ispSink_->links().empty())\n> +\t\treturn false;\n> +\n> +\tpad = ispSink_->links().at(0)->source();\n> +\tif (pad->entity()->function() == MEDIA_ENT_F_VID_IF_BRIDGE) {\n> +\t\tcsi_ = std::make_unique<V4L2Subdevice>(pad->entity());\n> +\t\tif (!csi_ || csi_->open() < 0)\n\nYou can drop the !csi_ check as std::make_unique<> never returns a null\npointer. With this fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\treturn false;\n> +\n> +\t\tispSink_ = csi_->entity()->getPadByIndex(0);\n> +\t\tif (!ispSink_)\n> +\t\t\treturn false;\n> +\t}\n> +\n>  \t/* Locate and open the stats and params video nodes. */\n>  \tstat_ = V4L2VideoDevice::fromEntityName(media_, \"rkisp1_stats\");\n>  \tif (stat_->open() < 0)\n> @@ -1038,12 +1070,8 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n>  \t * Enumerate all sensors connected to the ISP and create one\n>  \t * camera instance for each of them.\n>  \t */\n> -\tpad = isp_->entity()->getPadByIndex(0);\n> -\tif (!pad)\n> -\t\treturn false;\n> -\n>  \tbool registered = false;\n> -\tfor (MediaLink *link : pad->links()) {\n> +\tfor (MediaLink *link : ispSink_->links()) {\n>  \t\tif (!createCamera(link->source()->entity()))\n>  \t\t\tregistered = true;\n>  \t}","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 57E5BBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Jul 2022 15:51:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A1C666330E;\n\tWed, 13 Jul 2022 17:51:21 +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 2F9FB6274E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Jul 2022 17:51:20 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 848BC305;\n\tWed, 13 Jul 2022 17:51:19 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657727481;\n\tbh=zCwdZ0Nz5vV9xF/gqVD6I4VKQ9VtEJUdw061WGs2+JI=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=KSpQsWjOu1HFYlTB+OZ2xB2S4EpLGWgLGnxu7OksrGRYdjd0ensiI60e+3EDoeOS4\n\thQ7vtmkJgQdHZ0wF98v0RDBrjOH9sya/PkFbGuRKdVl1mq42uMjVg3B2NGOCmQ6eNn\n\tlJW9vVRFC88iFzNOptYX/JC1RMydpdN0W5iQiQkDuoVVX1ZX6wa8M2qsP/CYxahoFm\n\tgcBxgiEH2ONutViwVdD9pDpRAcU2LTY+tBH1IGqFjpkgkibp5vu8N2zFX1qn4mV9SJ\n\tL8PFROINSwdbLlPtwD0Q/hfkuL1tjhIAch3a1VjUm4lyA4HvaNp8dL8KYia9eEKMIE\n\tgcXd0y1G3wvnA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657727479;\n\tbh=zCwdZ0Nz5vV9xF/gqVD6I4VKQ9VtEJUdw061WGs2+JI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=aEQPNptsnYm3lpOlnsDApyA1tkqabmHIBzQUoH9+L5SPWCE03bOnXjlQtHhJMBe9r\n\tCBjCkOfuaP+dy5co1ZvoovWpxH5H02vZn1lV1YAEc4MCZLmykvqHL965eBBElT7FQT\n\tgrXJvWg0vB+ZpD5iFTPT1azcIPC6rb8Zr82iDXcI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"aEQPNpts\"; dkim-atps=neutral","Date":"Wed, 13 Jul 2022 18:50:49 +0300","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<Ys7p2aewI4cxqo/I@pendragon.ideasonboard.com>","References":"<20220713113443.220318-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220713113443.220318-1-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] pipeline: rkisp1: Support media\n\tgraph with separate CSI RX","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23865,"web_url":"https://patchwork.libcamera.org/comment/23865/","msgid":"<20220714072800.rvol7g4l37lmnpaj@uno.localdomain>","date":"2022-07-14T07:28:00","subject":"Re: [libcamera-devel] [PATCH v2] pipeline: rkisp1: Support media\n\tgraph with separate CSI RX","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Paul,\n\nOn Wed, Jul 13, 2022 at 06:50:49PM +0300, Laurent Pinchart via libcamera-devel wrote:\n> Hi Paul,\n>\n> Thank you for the patch.\n>\n> On Wed, Jul 13, 2022 at 08:34:43PM +0900, Paul Elder via libcamera-devel wrote:\n> > The rkisp1 hardware supports both a CSI-2 input and a parallel input,\n> > where the sensor is connected directly to the ISP. On RK3399, the CSI-2\n> > receiver is internal, but on the i.MX8MP, the CSI-2 receiver is a\n> > separate IP core, connected to the parallel input of the ISP, and gets\n> > exposed to userspace as a V4L2 subdev. To prepare for this, handle an\n> > optional CSI-2 receiver subdev in the pipeline.\n> >\n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> >\n> > ---\n> > Changes in v2:\n> > - clean up logic of determining pads/prescence of the CSI-2 receiver\n> >   subdev\n> > - upgrade the changelog\n> > ---\n> >  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 42 ++++++++++++++++++++----\n> >  1 file changed, 35 insertions(+), 7 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > index 3dc0850c..2b0ead5d 100644\n> > --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > @@ -178,6 +178,7 @@ private:\n> >  \tstd::unique_ptr<V4L2Subdevice> isp_;\n> >  \tstd::unique_ptr<V4L2VideoDevice> param_;\n> >  \tstd::unique_ptr<V4L2VideoDevice> stat_;\n> > +\tstd::unique_ptr<V4L2Subdevice> csi_;\n> >\n> >  \tRkISP1MainPath mainPath_;\n> >  \tRkISP1SelfPath selfPath_;\n> > @@ -188,6 +189,8 @@ private:\n> >  \tstd::queue<FrameBuffer *> availableStatBuffers_;\n> >\n> >  \tCamera *activeCamera_;\n> > +\n> > +\tconst MediaPad *ispSink_;\n> >  };\n> >\n> >  RkISP1Frames::RkISP1Frames(PipelineHandler *pipe)\n> > @@ -599,6 +602,12 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n> >\n> >  \tLOG(RkISP1, Debug) << \"Sensor configured with \" << format;\n> >\n> > +\tif (csi_) {\n> > +\t\tret = csi_->setFormat(0, &format);\n> > +\t\tif (ret < 0)\n> > +\t\t\treturn ret;\n> > +\t}\n> > +\n> >  \tret = isp_->setFormat(0, &format);\n> >  \tif (ret < 0)\n> >  \t\treturn ret;\n> > @@ -900,8 +909,7 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera,\n> >  \t * Configure the sensor links: enable the link corresponding to this\n> >  \t * camera.\n> >  \t */\n> > -\tconst MediaPad *pad = isp_->entity()->getPadByIndex(0);\n> > -\tfor (MediaLink *link : pad->links()) {\n> > +\tfor (MediaLink *link : ispSink_->links()) {\n> >  \t\tif (link->source()->entity() != sensor->entity())\n> >  \t\t\tcontinue;\n> >\n> > @@ -915,6 +923,14 @@ int PipelineHandlerRkISP1::initLinks(Camera *camera,\n> >  \t\t\treturn ret;\n> >  \t}\n> >\n> > +\tif (csi_) {\n> > +\t\tMediaLink *link = isp_->entity()->getPadByIndex(0)->links().at(0);\n> > +\n> > +\t\tret = link->setEnabled(true);\n> > +\t\tif (ret < 0)\n> > +\t\t\treturn ret;\n> > +\t}\n> > +\n> >  \tfor (const StreamConfiguration &cfg : config) {\n> >  \t\tif (cfg.stream() == &data->mainPathStream_)\n> >  \t\t\tret = data->mainPath_->setEnabled(true);\n> > @@ -1013,6 +1029,22 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n> >  \tif (isp_->open() < 0)\n> >  \t\treturn false;\n> >\n> > +\t/* Locate and open the optional CSI-2 receiver. */\n> > +\tispSink_ = isp_->entity()->getPadByIndex(0);\n> > +\tif (!ispSink_ || ispSink_->links().empty())\n> > +\t\treturn false;\n> > +\n> > +\tpad = ispSink_->links().at(0)->source();\n> > +\tif (pad->entity()->function() == MEDIA_ENT_F_VID_IF_BRIDGE) {\n> > +\t\tcsi_ = std::make_unique<V4L2Subdevice>(pad->entity());\n> > +\t\tif (!csi_ || csi_->open() < 0)\n>\n> You can drop the !csi_ check as std::make_unique<> never returns a null\n> pointer. With this fixed,\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n\nIndeed fixes the pipeline initialization with a separate CSI-2 receiver.\n\nTested-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\n> > +\t\t\treturn false;\n> > +\n> > +\t\tispSink_ = csi_->entity()->getPadByIndex(0);\n> > +\t\tif (!ispSink_)\n> > +\t\t\treturn false;\n> > +\t}\n> > +\n> >  \t/* Locate and open the stats and params video nodes. */\n> >  \tstat_ = V4L2VideoDevice::fromEntityName(media_, \"rkisp1_stats\");\n> >  \tif (stat_->open() < 0)\n> > @@ -1038,12 +1070,8 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n> >  \t * Enumerate all sensors connected to the ISP and create one\n> >  \t * camera instance for each of them.\n> >  \t */\n> > -\tpad = isp_->entity()->getPadByIndex(0);\n> > -\tif (!pad)\n> > -\t\treturn false;\n> > -\n> >  \tbool registered = false;\n> > -\tfor (MediaLink *link : pad->links()) {\n> > +\tfor (MediaLink *link : ispSink_->links()) {\n> >  \t\tif (!createCamera(link->source()->entity()))\n> >  \t\t\tregistered = true;\n> >  \t}\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 03B99BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Jul 2022 07:28:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5775163312;\n\tThu, 14 Jul 2022 09:28:03 +0200 (CEST)","from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A173763309\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Jul 2022 09:28:02 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id D099A1C0004;\n\tThu, 14 Jul 2022 07:28:01 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657783683;\n\tbh=8153a8LxFN1vz90SuZeU1ch7tI+AD3MLxaT4EWKkWPc=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=QH1IjffoNWLrKEqlh1HtGCitGhCWXuCoe3K8lhlkJCBynA/V9QlSbT3P21Gg9B/ic\n\tg04FOMMVxVXa1XccBFihBtFWZ9WFj7lqWodFWIPLYk0IUxZbFm2OpXu/82rWU2X1RG\n\tla1FckAGAa5A5OxEWlfVrF03uXSSJj9c8V479pLp0TN5AxMSEDB9Uofvkf8GckPLl1\n\tA5UOERohcDYSmUFklAGHR06rm11IiyuBmJ49GivEYJQZsNUEBYUu2MIVppDkKmFDy1\n\tI+aGwc8WFPun1l6xLox5xlxjlnof1PlmJfd1LUIJFMOxZULgU+xD0c27QrAt6Y5AVA\n\tikNxHp5CHG4KA==","Date":"Thu, 14 Jul 2022 09:28:00 +0200","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220714072800.rvol7g4l37lmnpaj@uno.localdomain>","References":"<20220713113443.220318-1-paul.elder@ideasonboard.com>\n\t<Ys7p2aewI4cxqo/I@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<Ys7p2aewI4cxqo/I@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] pipeline: rkisp1: Support media\n\tgraph with separate CSI RX","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]