summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Semkowicz via libcamera-devel <libcamera-devel@lists.libcamera.org>2022-06-28 11:06:54 +0200
committerJacopo Mondi <jacopo@jmondi.org>2022-07-14 17:06:46 +0200
commit094408e1220f70e17970b67d4c14d7aca31551b3 (patch)
tree47a8ed9e5a0bfbb7541914303d9c17121c4b0bb5
parent090ac6941679a49ea3c96de492a9f0ec00b2dd0c (diff)
libcamera: rkisp1: Control the lens from pipeline
Control lens focus from rkisp1 pipeline, using CameraLens controller and expose lens controls to the IPA during configure(). Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 212fc76a..d9c740d6 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"
@@ -107,6 +108,7 @@ private:
void paramFilled(unsigned int frame);
void setSensorControls(unsigned int frame,
const ControlList &sensorControls);
+ void setLensControls(const ControlList &lensControls);
void metadataReady(unsigned int frame, const ControlList &metadata);
};
@@ -374,6 +376,20 @@ void RkISP1CameraData::setSensorControls([[maybe_unused]] unsigned int frame,
delayedCtrls_->push(sensorControls);
}
+void RkISP1CameraData::setLensControls(const ControlList &lensControls)
+{
+ CameraLens *focusLens = sensor_->focusLens();
+ if (!focusLens)
+ return;
+
+ if (!lensControls.contains(V4L2_CID_FOCUS_ABSOLUTE))
+ return;
+
+ const ControlValue &focusValue = lensControls.get(V4L2_CID_FOCUS_ABSOLUTE);
+
+ focusLens->setFocusPosition(focusValue.get<int32_t>());
+}
+
void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata)
{
RkISP1FrameInfo *info = frameInfo_.find(frame);
@@ -681,6 +697,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 << ")";