[v7,4/5] pipeline: simple: Create DelayedControls instance once only
diff mbox series

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

Commit Message

Stanislaw Gruszka April 3, 2025, 7:45 a.m. UTC
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

The DelayedControls instance for the camera sensor is created in
SimplePipelineHandler::configure(). Constant deletion and reconstruction
of a new object is unnecessary, as the control delays are an intrinsic
property of the sensor and are known at initialization time. Move the
DelayedControls creation to the SimpleCameraData class constructor.

Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> # v6
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 | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Comments

Kieran Bingham April 3, 2025, 8:12 a.m. UTC | #1
Quoting Stanislaw Gruszka (2025-04-03 08:45:50)
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> The DelayedControls instance for the camera sensor is created in
> SimplePipelineHandler::configure(). Constant deletion and reconstruction
> of a new object is unnecessary, as the control delays are an intrinsic
> property of the sensor and are known at initialization time. Move the
> DelayedControls creation to the SimpleCameraData class constructor.
> 
> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> # v6
> 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>

I'll test this series on the x13s and merge as long as it's all fine.

--
Kieran

> ---
>  src/libcamera/pipeline/simple/simple.cpp | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index c97904076b63..262192b849e2 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -542,6 +542,13 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
>         if (!sensor_)
>                 return;
>  
> +       const CameraSensorProperties::SensorDelays &delays = sensor_->sensorDelays();
> +       std::unordered_map<uint32_t, DelayedControls::ControlParams> params = {
> +               { V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } },
> +               { V4L2_CID_EXPOSURE, { delays.exposureDelay, false } },
> +       };
> +       delayedCtrls_ = std::make_unique<DelayedControls>(sensor_->device(), params);
> +
>         LOG(SimplePipeline, Debug)
>                 << "Found pipeline: "
>                 << utils::join(entities_, " -> ",
> @@ -1388,15 +1395,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
>         if (outputCfgs.empty())
>                 return 0;
>  
> -       const CameraSensorProperties::SensorDelays &delays = data->sensor_->sensorDelays();
> -       std::unordered_map<uint32_t, DelayedControls::ControlParams> params = {
> -               { V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } },
> -               { V4L2_CID_EXPOSURE, { delays.exposureDelay, false } },
> -       };
> -       data->delayedCtrls_ =
> -               std::make_unique<DelayedControls>(data->sensor_->device(),
> -                                                 params);
> -
>         StreamConfiguration inputCfg;
>         inputCfg.pixelFormat = pipeConfig->captureFormat;
>         inputCfg.size = pipeConfig->captureSize;
> -- 
> 2.43.0
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index c97904076b63..262192b849e2 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -542,6 +542,13 @@  SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,
 	if (!sensor_)
 		return;
 
+	const CameraSensorProperties::SensorDelays &delays = sensor_->sensorDelays();
+	std::unordered_map<uint32_t, DelayedControls::ControlParams> params = {
+		{ V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } },
+		{ V4L2_CID_EXPOSURE, { delays.exposureDelay, false } },
+	};
+	delayedCtrls_ = std::make_unique<DelayedControls>(sensor_->device(), params);
+
 	LOG(SimplePipeline, Debug)
 		<< "Found pipeline: "
 		<< utils::join(entities_, " -> ",
@@ -1388,15 +1395,6 @@  int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
 	if (outputCfgs.empty())
 		return 0;
 
-	const CameraSensorProperties::SensorDelays &delays = data->sensor_->sensorDelays();
-	std::unordered_map<uint32_t, DelayedControls::ControlParams> params = {
-		{ V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } },
-		{ V4L2_CID_EXPOSURE, { delays.exposureDelay, false } },
-	};
-	data->delayedCtrls_ =
-		std::make_unique<DelayedControls>(data->sensor_->device(),
-						  params);
-
 	StreamConfiguration inputCfg;
 	inputCfg.pixelFormat = pipeConfig->captureFormat;
 	inputCfg.size = pipeConfig->captureSize;