summaryrefslogtreecommitdiff
path: root/src/ipa/ipu3
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-08-26 10:42:33 +0200
committerJacopo Mondi <jacopo@jmondi.org>2021-10-15 09:32:30 +0200
commit4ed22985a846dd9ab8d14505918e82f7d4dc3b8c (patch)
tree080eb461f5a73ea77cb91230c22539dc400d0a4c /src/ipa/ipu3
parent2a938efc8c55a6b59e0e9a1722e85415fe39b9c3 (diff)
ipa: ipu3: Update camera controls in configure()
When a new CameraConfiguration is applied to the Camera the IPA is configured as well, using the newly applied sensor configuration and its updated V4L2 controls. Also update the Camera controls at IPA::configure() time by re-computing the controls::ExposureTime and controls::FrameDurationLimits limits and update the controls on the pipeline handler side after having configured the IPA. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3')
-rw-r--r--src/ipa/ipu3/ipu3.cpp82
1 files changed, 56 insertions, 26 deletions
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 6d9bbf39..388f1902 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -171,13 +171,17 @@ public:
int start() override;
void stop() override {}
- int configure(const IPAConfigInfo &configInfo) override;
+ int configure(const IPAConfigInfo &configInfo,
+ ControlInfoMap *ipaControls) override;
void mapBuffers(const std::vector<IPABuffer> &buffers) override;
void unmapBuffers(const std::vector<unsigned int> &ids) override;
void processEvent(const IPU3Event &event) override;
private:
+ void updateControls(const IPACameraSensorInfo &sensorInfo,
+ const ControlInfoMap &sensorControls,
+ ControlInfoMap *ipaControls);
void processControls(unsigned int frame, const ControlList &controls);
void fillParams(unsigned int frame, ipu3_uapi_params *params);
void parseStatistics(unsigned int frame,
@@ -212,36 +216,30 @@ private:
struct IPAContext context_;
};
-/**
- * Initialize the IPA module and its controls.
+
+/*
+ * Compute camera controls using the sensor information and the sensor
+ * v4l2 controls.
*
- * This function receives the camera sensor information from the pipeline
- * handler, computes the limits of the controls it handles and returns
- * them in the \a ipaControls output parameter.
+ * Some of the camera controls are computed by the pipeline handler, some others
+ * by the IPA module which is in charge of handling, for example, the exposure
+ * time and the frame duration.
+ *
+ * This function computes:
+ * - controls::ExposureTime
+ * - controls::FrameDurationLimits
*/
-int IPAIPU3::init(const IPASettings &settings,
- const IPACameraSensorInfo &sensorInfo,
- const ControlInfoMap &sensorControls,
- ControlInfoMap *ipaControls)
+void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,
+ const ControlInfoMap &sensorControls,
+ ControlInfoMap *ipaControls)
{
- camHelper_ = CameraSensorHelperFactory::create(settings.sensorModel);
- if (camHelper_ == nullptr) {
- LOG(IPAIPU3, Error)
- << "Failed to create camera sensor helper for "
- << settings.sensorModel;
- return -ENODEV;
- }
-
- /* Initialize Controls. */
ControlInfoMap::Map controls{};
/*
- * Compute exposure time limits.
- *
- * Initialize the control using the line length and pixel rate of the
- * current configuration converted to microseconds. Use the
- * V4L2_CID_EXPOSURE control to get exposure min, max and default and
- * convert it from lines to microseconds.
+ * Compute exposure time limits by using line length and pixel rate
+ * converted to microseconds. Use the V4L2_CID_EXPOSURE control to get
+ * exposure min, max and default and convert it from lines to
+ * microseconds.
*/
double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);
const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;
@@ -279,6 +277,27 @@ int IPAIPU3::init(const IPASettings &settings,
frameDurations[2]);
*ipaControls = ControlInfoMap(std::move(controls), controls::controls);
+}
+
+/**
+ * Initialize the IPA module and its controls.
+ *
+ * This function receives the camera sensor information from the pipeline
+ * handler, computes the limits of the controls it handles and returns
+ * them in the \a ipaControls output parameter.
+ */
+int IPAIPU3::init(const IPASettings &settings,
+ const IPACameraSensorInfo &sensorInfo,
+ const ControlInfoMap &sensorControls,
+ ControlInfoMap *ipaControls)
+{
+ camHelper_ = CameraSensorHelperFactory::create(settings.sensorModel);
+ if (camHelper_ == nullptr) {
+ LOG(IPAIPU3, Error)
+ << "Failed to create camera sensor helper for "
+ << settings.sensorModel;
+ return -ENODEV;
+ }
/* Construct our Algorithms */
algorithms_.push_back(std::make_unique<algorithms::Agc>());
@@ -286,6 +305,9 @@ int IPAIPU3::init(const IPASettings &settings,
algorithms_.push_back(std::make_unique<algorithms::BlackLevelCorrection>());
algorithms_.push_back(std::make_unique<algorithms::ToneMapping>());
+ /* Initialize controls. */
+ updateControls(sensorInfo, sensorControls, ipaControls);
+
return 0;
}
@@ -365,7 +387,8 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize)
<< (int)bdsGrid.height << " << " << (int)bdsGrid.block_height_log2 << ")";
}
-int IPAIPU3::configure(const IPAConfigInfo &configInfo)
+int IPAIPU3::configure(const IPAConfigInfo &configInfo,
+ ControlInfoMap *ipaControls)
{
if (configInfo.sensorControls.empty()) {
LOG(IPAIPU3, Error) << "No sensor controls provided";
@@ -374,6 +397,10 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)
sensorInfo_ = configInfo.sensorInfo;
+ /*
+ * Compute the sensor V4L2 controls to be used by the algorithms and
+ * to be set on the sensor.
+ */
ctrls_ = configInfo.sensorControls;
const auto itExp = ctrls_.find(V4L2_CID_EXPOSURE);
@@ -415,6 +442,9 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)
return ret;
}
+ /* Update the camera controls using the new sensor settings. */
+ updateControls(sensorInfo_, ctrls_, ipaControls);
+
return 0;
}