[libcamera-devel,RFC,1/7] ipa: rkisp1: add basic camera lens support
diff mbox series

Message ID 20230202111252.3366729-2-matthias.fend@emfend.at
State New
Headers show
Series
  • add support for more complex optics
Related show

Commit Message

Matthias Fend Feb. 2, 2023, 11:12 a.m. UTC
Adding basic support for lenses, as has been done similarly in other
pipeline handlers.
Parts of it will be changed later in the series, but the intended changes
are more recognizable.

Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
---
 include/libcamera/ipa/rkisp1.mojom       |  4 +++-
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 21 +++++++++++++++++++--
 2 files changed, 22 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom
index 1009e970..d33e93df 100644
--- a/include/libcamera/ipa/rkisp1.mojom
+++ b/include/libcamera/ipa/rkisp1.mojom
@@ -11,6 +11,7 @@  import "include/libcamera/ipa/core.mojom";
 struct IPAConfigInfo {
 	libcamera.IPACameraSensorInfo sensorInfo;
 	libcamera.ControlInfoMap sensorControls;
+	libcamera.ControlInfoMap lensControls;
 };
 
 interface IPARkISP1Interface {
@@ -37,6 +38,7 @@  interface IPARkISP1Interface {
 
 interface IPARkISP1EventInterface {
 	paramsBufferReady(uint32 frame);
-	setSensorControls(uint32 frame, libcamera.ControlList sensorControls);
+	setSensorControls(uint32 frame, libcamera.ControlList sensorControls,
+			  libcamera.ControlList lensControls);
 	metadataReady(uint32 frame, libcamera.ControlList metadata);
 };
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 5f22a29d..d4fbcf4b 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -32,6 +32,7 @@ 
 #include <libcamera/ipa/rkisp1_ipa_proxy.h>
 
 #include "libcamera/internal/camera.h"
+#include "libcamera/internal/camera_lens.h"
 #include "libcamera/internal/camera_sensor.h"
 #include "libcamera/internal/delayed_controls.h"
 #include "libcamera/internal/device_enumerator.h"
@@ -112,7 +113,8 @@  public:
 private:
 	void paramFilled(unsigned int frame);
 	void setSensorControls(unsigned int frame,
-			       const ControlList &sensorControls);
+			       const ControlList &sensorControls,
+			       const ControlList &lensControls);
 
 	void metadataReady(unsigned int frame, const ControlList &metadata);
 };
@@ -395,9 +397,20 @@  void RkISP1CameraData::paramFilled(unsigned int frame)
 }
 
 void RkISP1CameraData::setSensorControls([[maybe_unused]] unsigned int frame,
-					 const ControlList &sensorControls)
+					 const ControlList &sensorControls,
+					 const ControlList &lensControls)
 {
 	delayedCtrls_->push(sensorControls);
+
+	CameraLens *lens = sensor_->focusLens();
+	if (!lens)
+		return;
+
+	if (lensControls.contains(V4L2_CID_FOCUS_ABSOLUTE)) {
+		const ControlValue &focusValue = lensControls.get(V4L2_CID_FOCUS_ABSOLUTE);
+
+		lens->setFocusPosition(focusValue.get<int32_t>());
+	}
 }
 
 void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata)
@@ -810,6 +823,10 @@  int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
 
 	ipaConfig.sensorControls = data->sensor_->controls();
 
+	CameraLens *lens = data->sensor_->focusLens();
+	if (lens)
+		ipaConfig.lensControls = lens->controls();
+
 	ret = data->ipa_->configure(ipaConfig, streamConfig, &data->controlInfo_);
 	if (ret) {
 		LOG(RkISP1, Error) << "failed configuring IPA (" << ret << ")";