summaryrefslogtreecommitdiff
path: root/src/ipa/rkisp1/rkisp1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/rkisp1/rkisp1.cpp')
-rw-r--r--src/ipa/rkisp1/rkisp1.cpp36
1 files changed, 36 insertions, 0 deletions
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)