[libcamera-devel,v3,09/17] rkisp1: Add camera lens to PH and expose it to the IPA
diff mbox series

Message ID 20220818094410.1671-10-jacopo@jmondi.org
State New
Headers show
Series
  • libcamera: Align IPU3 and RKISP1 interfaces
Related show

Commit Message

Jacopo Mondi Aug. 18, 2022, 9:44 a.m. UTC
From: Daniel Semkowicz via libcamera-devel <libcamera-devel@lists.libcamera.org>

Check in pipeline handler if camera lens exists, add expose its controls
to the IPA.

Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/ipa/rkisp1/rkisp1.cpp                | 6 ++++++
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 +++++
 2 files changed, 11 insertions(+)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 15d1a40fbb9a..3a98aaf75d98 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -7,6 +7,7 @@ 
 
 #include <algorithm>
 #include <math.h>
+#include <optional>
 #include <queue>
 #include <stdint.h>
 #include <string.h>
@@ -70,6 +71,7 @@  private:
 	std::map<unsigned int, MappedFrameBuffer> mappedBuffers_;
 
 	ControlInfoMap sensorCtrls_;
+	std::optional<ControlInfoMap> lensCtrls_;
 
 	/* Camera sensor controls. */
 	bool autoExposure_;
@@ -206,6 +208,10 @@  int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,
 
 	sensorCtrls_ = entityControls.at(0);
 
+	auto lensControls = entityControls.find(1);
+	if (lensControls != entityControls.end())
+		lensCtrls_ = lensControls->second;
+
 	const auto itExp = sensorCtrls_.find(V4L2_CID_EXPOSURE);
 	if (itExp == sensorCtrls_.end()) {
 		LOG(IPARkISP1, Error) << "Can't find exposure control";
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 932873329e89..5f10c26bcb4d 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -28,6 +28,7 @@ 
 #include <libcamera/stream.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"
@@ -694,6 +695,10 @@  int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
 	std::map<uint32_t, ControlInfoMap> entityControls;
 	entityControls.emplace(0, data->sensor_->controls());
 
+	CameraLens *lens = data->sensor_->focusLens();
+	if (lens)
+		entityControls.emplace(1, lens->controls());
+
 	ret = data->ipa_->configure(sensorInfo, streamConfig, entityControls);
 	if (ret) {
 		LOG(RkISP1, Error) << "failed configuring IPA (" << ret << ")";