[{"id":33523,"web_url":"https://patchwork.libcamera.org/comment/33523/","msgid":"<174087128191.3864332.6993178437519450264@ping.linuxembedded.co.uk>","date":"2025-03-01T23:21:21","subject":"Re: [PATCH v5 2/5] pipeline: simple: Use proper device for frame\n\tstart events","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stanislaw Gruszka (2025-02-25 16:41:13)\n> Currently we use frame start event from video capture device to\n> apply controls. But the capture device might not generate the events.\n> Usually CSI-2 receiver is proper device to subscribe for start\n> frame events.\n> \n> To fix, loop over devices in the pipeline to find the one that\n> supports events and use it as start frame emitter.\n> \n> Co-developed-by: Hans de Goede <hdegoede@redhat.com>\n> Signed-off-by: Hans de Goede <hdegoede@redhat.com>\n> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>\n\nThis is something that I should incorporate into the MediaPipeline (or\nCameraPipeline, or Pipeline?) class I have worked on to generalise\ncamera pipes...\n\nBut I think it's helpful here now.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 20 ++++++++++++++++++--\n>  1 file changed, 18 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 6e039bf3..063a098f 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -277,6 +277,7 @@ public:\n>         std::list<Entity> entities_;\n>         std::unique_ptr<CameraSensor> sensor_;\n>         V4L2VideoDevice *video_;\n> +       V4L2Subdevice *frameStartEmitter_;\n>  \n>         std::vector<Configuration> configs_;\n>         std::map<PixelFormat, std::vector<const Configuration *>> formats_;\n> @@ -579,6 +580,19 @@ int SimpleCameraData::init()\n>  \n>         properties_ = sensor_->properties();\n>  \n> +       frameStartEmitter_ = nullptr;\n> +       for (const Entity &entity : entities_) {\n> +               V4L2Subdevice *sd = pipe->subdev(entity.entity);\n> +               if (!sd || !sd->supportsFrameStartEvent())\n> +                       continue;\n> +\n> +               LOG(SimplePipeline, Debug)\n> +                       << \"Using \" << entity.entity->name() << \" frameStart signal\";\n> +\n> +               frameStartEmitter_ = sd;\n> +               break;\n> +       }\n> +\n>         return 0;\n>  }\n>  \n> @@ -1215,6 +1229,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n>                 static_cast<SimpleCameraConfiguration *>(c);\n>         SimpleCameraData *data = cameraData(camera);\n>         V4L2VideoDevice *video = data->video_;\n> +       V4L2Subdevice *frameStartEmitter = data->frameStartEmitter_;\n>         int ret;\n>  \n>         /*\n> @@ -1285,8 +1300,9 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n>         data->delayedCtrls_ =\n>                 std::make_unique<DelayedControls>(data->sensor_->device(),\n>                                                   params);\n> -       data->video_->frameStart.connect(data->delayedCtrls_.get(),\n> -                                        &DelayedControls::applyControls);\n> +       if (frameStartEmitter)\n> +               frameStartEmitter->frameStart.connect(data->delayedCtrls_.get(),\n> +                                                     &DelayedControls::applyControls);\n>  \n>         StreamConfiguration inputCfg;\n>         inputCfg.pixelFormat = pipeConfig->captureFormat;\n> -- \n> 2.43.0\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 5EAEEC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  1 Mar 2025 23:21:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7C72D68754;\n\tSun,  2 Mar 2025 00:21:27 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35D7861853\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  2 Mar 2025 00:21:25 +0100 (CET)","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 B2D53666;\n\tSun,  2 Mar 2025 00:19:54 +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=\"tG6F0iUY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740871194;\n\tbh=e+Mv/KvGBfoCBmgpuJQSe/a+jj0poNvIT2HQDPK33Bg=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=tG6F0iUYePeqWChaIOdDu8nkjFMc5vcdTqKDpiar+iIf/bZRNkBLBVBOhXxxymxWz\n\tsHRf0NRf3MQGf0iR3fxSHQuBomGr304akcaJCT+BJgzZVGMnLjZzCBOlJ7JSvjAjJt\n\tfEK2FdzLHiNgnutQZButJcJMOWwITTfDSedIYBsU=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250225164116.414301-3-stanislaw.gruszka@linux.intel.com>","References":"<20250225164116.414301-1-stanislaw.gruszka@linux.intel.com>\n\t<20250225164116.414301-3-stanislaw.gruszka@linux.intel.com>","Subject":"Re: [PATCH v5 2/5] pipeline: simple: Use proper device for frame\n\tstart events","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>,\n\tSakari Ailus <sakari.ailus@linux.intel.com>,\n\tHans de Goede <hdegoede@redhat.com>","To":"Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Sat, 01 Mar 2025 23:21:21 +0000","Message-ID":"<174087128191.3864332.6993178437519450264@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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":33528,"web_url":"https://patchwork.libcamera.org/comment/33528/","msgid":"<20250302005913.GD18557@pendragon.ideasonboard.com>","date":"2025-03-02T00:59:13","subject":"Re: [PATCH v5 2/5] pipeline: simple: Use proper device for frame\n\tstart events","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stanislaw,\n\nThank you for the patch.\n\nOn Tue, Feb 25, 2025 at 05:41:13PM +0100, Stanislaw Gruszka wrote:\n> Currently we use frame start event from video capture device to\n> apply controls. But the capture device might not generate the events.\n> Usually CSI-2 receiver is proper device to subscribe for start\n> frame events.\n> \n> To fix, loop over devices in the pipeline to find the one that\n\ns/the one/the first one/\n\n> supports events and use it as start frame emitter.\n> \n> Co-developed-by: Hans de Goede <hdegoede@redhat.com>\n> Signed-off-by: Hans de Goede <hdegoede@redhat.com>\n> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 20 ++++++++++++++++++--\n>  1 file changed, 18 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 6e039bf3..063a098f 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -277,6 +277,7 @@ public:\n>  \tstd::list<Entity> entities_;\n>  \tstd::unique_ptr<CameraSensor> sensor_;\n>  \tV4L2VideoDevice *video_;\n> +\tV4L2Subdevice *frameStartEmitter_;\n>  \n>  \tstd::vector<Configuration> configs_;\n>  \tstd::map<PixelFormat, std::vector<const Configuration *>> formats_;\n> @@ -579,6 +580,19 @@ int SimpleCameraData::init()\n>  \n>  \tproperties_ = sensor_->properties();\n>  \n\n\t/* Find the first subdev that can generate a frame start signal, if any. */\n\n> +\tframeStartEmitter_ = nullptr;\n> +\tfor (const Entity &entity : entities_) {\n> +\t\tV4L2Subdevice *sd = pipe->subdev(entity.entity);\n> +\t\tif (!sd || !sd->supportsFrameStartEvent())\n> +\t\t\tcontinue;\n> +\n> +\t\tLOG(SimplePipeline, Debug)\n> +\t\t\t<< \"Using \" << entity.entity->name() << \" frameStart signal\";\n\nLet's quote the name as it can contain spaces.\n\n\t\t\t<< \"Using frameStart signal from '\"\n\t\t\t<< entity.entity->name() << \"'\";\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n> +\t\tframeStartEmitter_ = sd;\n> +\t\tbreak;\n> +\t}\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -1215,6 +1229,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n>  \t\tstatic_cast<SimpleCameraConfiguration *>(c);\n>  \tSimpleCameraData *data = cameraData(camera);\n>  \tV4L2VideoDevice *video = data->video_;\n> +\tV4L2Subdevice *frameStartEmitter = data->frameStartEmitter_;\n>  \tint ret;\n>  \n>  \t/*\n> @@ -1285,8 +1300,9 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n>  \tdata->delayedCtrls_ =\n>  \t\tstd::make_unique<DelayedControls>(data->sensor_->device(),\n>  \t\t\t\t\t\t  params);\n> -\tdata->video_->frameStart.connect(data->delayedCtrls_.get(),\n> -\t\t\t\t\t &DelayedControls::applyControls);\n> +\tif (frameStartEmitter)\n> +\t\tframeStartEmitter->frameStart.connect(data->delayedCtrls_.get(),\n> +\t\t\t\t\t\t      &DelayedControls::applyControls);\n>  \n>  \tStreamConfiguration inputCfg;\n>  \tinputCfg.pixelFormat = pipeConfig->captureFormat;","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 EF298C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  2 Mar 2025 00:59:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DEC6668779;\n\tSun,  2 Mar 2025 01:59:34 +0100 (CET)","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 AA05F61833\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  2 Mar 2025 01:59:32 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 080017E9;\n\tSun,  2 Mar 2025 01:58:01 +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=\"AcbkFZ4u\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740877082;\n\tbh=9UeHMlaV8+COwZ6Wt3LMokJt8QhO5cWuUIrpBX92pvA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AcbkFZ4uqysAdTFaZ6WWoTI9vAeUDCQ1Al+9lOfWkUoCE55rsg4GV2JDK9JMY1SgV\n\ttoZY7gb5WnYqpDeroyZz1lv/hPgiU3VFsXkgkEr4XTYfjhWh6gm94xLUb0qJI8HDhe\n\tEdI9Kp02DFnxH9cUWhD8QDxC7yTWkSVJfVeNnHBw=","Date":"Sun, 2 Mar 2025 02:59:13 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>","Cc":"libcamera-devel@lists.libcamera.org, Milan Zamazal <mzamazal@redhat.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>,\n\tSakari Ailus <sakari.ailus@linux.intel.com>,\n\tHans de Goede <hdegoede@redhat.com>","Subject":"Re: [PATCH v5 2/5] pipeline: simple: Use proper device for frame\n\tstart events","Message-ID":"<20250302005913.GD18557@pendragon.ideasonboard.com>","References":"<20250225164116.414301-1-stanislaw.gruszka@linux.intel.com>\n\t<20250225164116.414301-3-stanislaw.gruszka@linux.intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250225164116.414301-3-stanislaw.gruszka@linux.intel.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>"}}]