summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-01-23 15:49:24 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-01-30 16:30:43 +0000
commitb9923747ad28bea8b9466c7205a0db4d56545716 (patch)
tree111e75e5644a4dc4bb1b45c7f5f9af3e1dc950fc
parentc204a67bae262945cf5455e475e79a6b626a7827 (diff)
pipeline: ipa: raspberrypi: Validate lens controls
Pass the available lens controls to the IPA through the configure() function. Validate that the V4L2_CID_FOCUS_ABSOLUTE does exist. If it doesn't, log a warning message, and do not advertise focus related controls from the IPA. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--include/libcamera/ipa/raspberrypi.mojom1
-rw-r--r--src/ipa/raspberrypi/raspberrypi.cpp21
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp3
3 files changed, 25 insertions, 0 deletions
diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom
index 2a4821fb..bfacd127 100644
--- a/include/libcamera/ipa/raspberrypi.mojom
+++ b/include/libcamera/ipa/raspberrypi.mojom
@@ -38,6 +38,7 @@ struct IPAConfig {
libcamera.SharedFD lsTableHandle;
libcamera.ControlInfoMap sensorControls;
libcamera.ControlInfoMap ispControls;
+ libcamera.ControlInfoMap lensControls;
};
struct IPAConfigResult {
diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
index aa18ed75..bbf3c7dc 100644
--- a/src/ipa/raspberrypi/raspberrypi.cpp
+++ b/src/ipa/raspberrypi/raspberrypi.cpp
@@ -131,6 +131,7 @@ private:
void setMode(const IPACameraSensorInfo &sensorInfo);
bool validateSensorControls();
bool validateIspControls();
+ bool validateLensControls();
void queueRequest(const ControlList &controls);
void returnEmbeddedBuffer(unsigned int bufferId);
void prepareISP(const ISPConfig &data);
@@ -155,6 +156,7 @@ private:
ControlInfoMap sensorCtrls_;
ControlInfoMap ispCtrls_;
+ ControlInfoMap lensCtrls_;
bool lensPresent_;
ControlList libcameraMetadata_;
@@ -394,6 +396,15 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ip
return -1;
}
+ if (lensPresent_) {
+ lensCtrls_ = ipaConfig.lensControls;
+ if (!validateLensControls()) {
+ LOG(IPARPI, Warning) << "Lens validation failed, "
+ << "no lens control will be available.";
+ lensPresent_ = false;
+ }
+ }
+
maxSensorGainCode_ = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN).max().get<int32_t>();
/* Setup a metadata ControlList to output metadata. */
@@ -648,6 +659,16 @@ bool IPARPi::validateIspControls()
return true;
}
+bool IPARPi::validateLensControls()
+{
+ if (lensCtrls_.find(V4L2_CID_FOCUS_ABSOLUTE) == lensCtrls_.end()) {
+ LOG(IPARPI, Error) << "Unable to find Lens control V4L2_CID_FOCUS_ABSOLUTE";
+ return false;
+ }
+
+ return true;
+}
+
/*
* Converting between enums (used in the libcamera API) and the names that
* we use to identify different modes. Unfortunately, the conversion tables
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 381271ad..9d1596ab 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1522,8 +1522,11 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA
std::map<unsigned int, ControlInfoMap> entityControls;
ipa::RPi::IPAConfig ipaConfig;
+ /* \todo Move passing of ispControls and lensControls to ipa::init() */
ipaConfig.sensorControls = sensor_->controls();
ipaConfig.ispControls = isp_[Isp::Input].dev()->controls();
+ if (sensor_->focusLens())
+ ipaConfig.lensControls = sensor_->focusLens()->controls();
/* Always send the user transform to the IPA. */
ipaConfig.transform = static_cast<unsigned int>(config->transform);