summaryrefslogtreecommitdiff
path: root/src/ipa/rkisp1
diff options
context:
space:
mode:
authorDaniel Semkowicz via libcamera-devel <libcamera-devel@lists.libcamera.org>2022-06-28 11:06:56 +0200
committerJacopo Mondi <jacopo@jmondi.org>2022-07-14 17:06:46 +0200
commitc0ec98a6b90bb55e838f2cff272503ee55db456a (patch)
treeda856edd3139c6a6aafb3303521f4c8fb0c78f72 /src/ipa/rkisp1
parent7c52f539350998bda947a9083dc6c83ab7dd8273 (diff)
libcamera: rkisp1: Control the lens from IPA
Check if lens are available and have ability to control the focus. Connect IPA setLensControls() signal to the pipeline slot that controls the lens. If lens are valid, allow changing the focus from IPA by emitting signal to the pipeline. Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>
Diffstat (limited to 'src/ipa/rkisp1')
-rw-r--r--src/ipa/rkisp1/ipa_context.h4
-rw-r--r--src/ipa/rkisp1/rkisp1.cpp36
2 files changed, 40 insertions, 0 deletions
diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
index f387cace..4b199048 100644
--- a/src/ipa/rkisp1/ipa_context.h
+++ b/src/ipa/rkisp1/ipa_context.h
@@ -42,6 +42,10 @@ struct IPASessionConfiguration {
struct IPAFrameContext {
struct {
+ uint32_t focus;
+ } af;
+
+ struct {
uint32_t exposure;
double gain;
} agc;
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 33642094..01bb54fb 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>
@@ -65,6 +66,8 @@ protected:
std::string logPrefix() const override;
private:
+ bool validateLensControls(const ControlInfoMap &lensControls);
+
void setControls(unsigned int frame);
void prepareMetadata(unsigned int frame, unsigned int aeState);
@@ -72,6 +75,7 @@ private:
std::map<unsigned int, MappedFrameBuffer> mappedBuffers_;
ControlInfoMap sensorCtrls_;
+ std::optional<ControlInfoMap> lensCtrls_;
/* Camera sensor controls. */
bool autoExposure_;
@@ -192,6 +196,14 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,
return -EINVAL;
}
+ auto lensControls = entityControls.find(1);
+ if (lensControls != entityControls.end()) {
+ if (validateLensControls(lensControls->second))
+ lensCtrls_ = lensControls->second;
+ else
+ LOG(IPARkISP1, Error) << "Lens control validation failed.";
+ }
+
autoExposure_ = true;
int32_t minExposure = itExp->second.min().get<int32_t>();
@@ -235,6 +247,23 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,
return 0;
}
+bool IPARkISP1::validateLensControls(const ControlInfoMap &lensControls)
+{
+ static const uint32_t ctrls[] = {
+ V4L2_CID_FOCUS_ABSOLUTE,
+ };
+
+ for (auto c : ctrls) {
+ if (lensControls.find(c) == lensControls.end()) {
+ LOG(IPARkISP1, Error) << "Unable to find lens control "
+ << utils::hex(c);
+ return false;
+ }
+ }
+
+ return true;
+}
+
void IPARkISP1::mapBuffers(const std::vector<IPABuffer> &buffers)
{
for (const IPABuffer &buffer : buffers) {
@@ -319,6 +348,13 @@ void IPARkISP1::setControls(unsigned int frame)
ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast<int32_t>(gain));
setSensorControls.emit(frame, ctrls);
+
+ if (lensCtrls_) {
+ ControlList lensCtrls(*lensCtrls_);
+ lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE,
+ static_cast<int32_t>(context_.frameContext.af.focus));
+ setLensControls.emit(lensCtrls);
+ }
}
void IPARkISP1::prepareMetadata(unsigned int frame, unsigned int aeState)