[v7,2/5] pipeline: simple: Connect/disconnect frameStart signal at start/stop time
diff mbox series

Message ID 20250403074551.263496-3-stanislaw.gruszka@linux.intel.com
State Accepted
Commit 2f7bece17baaf40115c062bd537f63854d79a63e
Headers show
Series
  • libcamera: start frame events changes
Related show

Commit Message

Stanislaw Gruszka April 3, 2025, 7:45 a.m. UTC
The frameStart signal from the frame start emitter is connected in the
configure() function, and is never disconnected. This means that each
time the camera is configured a new connection is made, causing the
DelayedControls::applyControls() to be called multiple times. Fix it by
connecting and disconnecting the signal when starting and stopping the
camera.

Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> # v6
Co-developed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
---
 src/libcamera/pipeline/simple/simple.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Kieran Bingham April 3, 2025, 8:07 a.m. UTC | #1
Quoting Stanislaw Gruszka (2025-04-03 08:45:48)
> The frameStart signal from the frame start emitter is connected in the
> configure() function, and is never disconnected. This means that each
> time the camera is configured a new connection is made, causing the
> DelayedControls::applyControls() to be called multiple times. Fix it by
> connecting and disconnecting the signal when starting and stopping the
> camera.
> 
> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> # v6
> Co-developed-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/libcamera/pipeline/simple/simple.cpp | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index fd0ccdca8ebe..06e805d89caa 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -1371,8 +1371,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
>         data->delayedCtrls_ =
>                 std::make_unique<DelayedControls>(data->sensor_->device(),
>                                                   params);
> -       data->video_->frameStart.connect(data->delayedCtrls_.get(),
> -                                        &DelayedControls::applyControls);
>  
>         StreamConfiguration inputCfg;
>         inputCfg.pixelFormat = pipeConfig->captureFormat;
> @@ -1440,6 +1438,9 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL
>  
>         video->bufferReady.connect(data, &SimpleCameraData::imageBufferReady);
>  
> +       data->video_->frameStart.connect(data->delayedCtrls_.get(),
> +                                        &DelayedControls::applyControls);
> +
>         ret = video->streamOn();
>         if (ret < 0) {
>                 stop(camera);
> @@ -1472,6 +1473,9 @@ void SimplePipelineHandler::stopDevice(Camera *camera)
>         SimpleCameraData *data = cameraData(camera);
>         V4L2VideoDevice *video = data->video_;
>  
> +       data->video_->frameStart.disconnect(data->delayedCtrls_.get(),
> +                                           &DelayedControls::applyControls);
> +
>         if (data->useConversion_) {
>                 if (data->converter_)
>                         data->converter_->stop();
> -- 
> 2.43.0
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index fd0ccdca8ebe..06e805d89caa 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -1371,8 +1371,6 @@  int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
 	data->delayedCtrls_ =
 		std::make_unique<DelayedControls>(data->sensor_->device(),
 						  params);
-	data->video_->frameStart.connect(data->delayedCtrls_.get(),
-					 &DelayedControls::applyControls);
 
 	StreamConfiguration inputCfg;
 	inputCfg.pixelFormat = pipeConfig->captureFormat;
@@ -1440,6 +1438,9 @@  int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL
 
 	video->bufferReady.connect(data, &SimpleCameraData::imageBufferReady);
 
+	data->video_->frameStart.connect(data->delayedCtrls_.get(),
+					 &DelayedControls::applyControls);
+
 	ret = video->streamOn();
 	if (ret < 0) {
 		stop(camera);
@@ -1472,6 +1473,9 @@  void SimplePipelineHandler::stopDevice(Camera *camera)
 	SimpleCameraData *data = cameraData(camera);
 	V4L2VideoDevice *video = data->video_;
 
+	data->video_->frameStart.disconnect(data->delayedCtrls_.get(),
+					    &DelayedControls::applyControls);
+
 	if (data->useConversion_) {
 		if (data->converter_)
 			data->converter_->stop();