[libcamera-devel,v2,6/8] libcamera: pipeline: rkisp1: Use CameraSensor and delayed controls
diff mbox series

Message ID 20201110002710.3233696-7-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • Add helper for controls that take effect with a delay
Related show

Commit Message

Niklas Söderlund Nov. 10, 2020, 12:27 a.m. UTC
Instead of setting controls using the RkISP1 local Timeline helper use
the DelayedControls interface provided by the CameraSensor. The result
are the same, the controls are applied with a delay.

The values of the delays are however different between the two methods.
The values used in the Timeline solution was chosen after some
experimentation and the values used in DelayedControls are taken from a
generic sensor. None of the two are a perfect match as the delays can be
different for different sensors used with the pipeline.

However using the interface provided by CameraSensor we prepare for the
future where sensor specific delays will provided by the CameraSensor
and used without any change in the pipeline.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 35 +++++++++---------------
 1 file changed, 13 insertions(+), 22 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 1b1922a9896c1cc0..6b71fdd1db00460b 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -121,8 +121,9 @@  class RkISP1CameraData : public CameraData
 public:
 	RkISP1CameraData(PipelineHandler *pipe, RkISP1MainPath *mainPath,
 			 RkISP1SelfPath *selfPath)
-		: CameraData(pipe), sensor_(nullptr), frame_(0),
-		  frameInfo_(pipe), mainPath_(mainPath), selfPath_(selfPath)
+		: CameraData(pipe), sensor_(nullptr), delayedCtrls_(nullptr),
+		  frame_(0), frameInfo_(pipe), mainPath_(mainPath),
+		  selfPath_(selfPath)
 	{
 	}
 
@@ -136,6 +137,7 @@  public:
 	Stream mainPathStream_;
 	Stream selfPathStream_;
 	CameraSensor *sensor_;
+	DelayedControls *delayedCtrls_;
 	unsigned int frame_;
 	std::vector<IPABuffer> ipaBuffers_;
 	RkISP1Frames frameInfo_;
@@ -346,23 +348,6 @@  RkISP1FrameInfo *RkISP1Frames::find(Request *request)
 	return nullptr;
 }
 
-class RkISP1ActionSetSensor : public FrameAction
-{
-public:
-	RkISP1ActionSetSensor(unsigned int frame, CameraSensor *sensor, const ControlList &controls)
-		: FrameAction(frame, SetSensor), sensor_(sensor), controls_(controls) {}
-
-protected:
-	void run() override
-	{
-		sensor_->setControls(&controls_);
-	}
-
-private:
-	CameraSensor *sensor_;
-	ControlList controls_;
-};
-
 class RkISP1ActionQueueBuffers : public FrameAction
 {
 public:
@@ -430,9 +415,7 @@  void RkISP1CameraData::queueFrameAction(unsigned int frame,
 	switch (action.operation) {
 	case RKISP1_IPA_ACTION_V4L2_SET: {
 		const ControlList &controls = action.controls[0];
-		timeline_.scheduleAction(std::make_unique<RkISP1ActionSetSensor>(frame,
-										 sensor_,
-										 controls));
+		delayedCtrls_->push(controls);
 		break;
 	}
 	case RKISP1_IPA_ACTION_PARAM_FILLED: {
@@ -896,6 +879,8 @@  int PipelineHandlerRkISP1::start(Camera *camera)
 		};
 	}
 
+	isp_->setFrameStartEnabled(true);
+
 	activeCamera_ = camera;
 
 	/* Inform IPA of stream configuration and sensor controls. */
@@ -923,6 +908,8 @@  void PipelineHandlerRkISP1::stop(Camera *camera)
 	RkISP1CameraData *data = cameraData(camera);
 	int ret;
 
+	isp_->setFrameStartEnabled(false);
+
 	selfPath_.stop();
 	mainPath_.stop();
 
@@ -1041,6 +1028,10 @@  int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)
 	/* Initialize the camera properties. */
 	data->properties_ = data->sensor_->properties();
 
+	data->delayedCtrls_ = data->sensor_->delayedContols();
+	isp_->frameStart.connect(data->delayedCtrls_,
+				 &DelayedControls::frameStart);
+
 	ret = data->loadIPA();
 	if (ret)
 		return ret;