[libcamera-devel] [PATCH v3 15/17] ipa: ipu3: Validate controls before assigning them
Jacopo Mondi
jacopo at jmondi.org
Thu Aug 18 11:44:08 CEST 2022
The IPU3 IPA configure() implementation assigns to the class member
sensorCtrls_ the list of controls before having validated it.
Rework the flow of operations to first validate the controls and then
copy them in the class member variables.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/ipa/ipu3/ipu3.cpp | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 072d6cc28f33..dd9d21e4df52 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -161,7 +161,7 @@ protected:
std::string logPrefix() const override;
private:
- bool validateSensorControls();
+ bool validateSensorControls(const ControlInfoMap &sensorCtrls);
void updateControls(const IPACameraSensorInfo &sensorInfo,
const ControlInfoMap &sensorControls,
ControlInfoMap *ipaControls);
@@ -343,7 +343,7 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize)
/**
* \brief Validate that the sensor controls mandatory for the IPA exists
*/
-bool IPAIPU3::validateSensorControls()
+bool IPAIPU3::validateSensorControls(const ControlInfoMap &sensorCtrls)
{
static const uint32_t ctrls[] = {
V4L2_CID_ANALOGUE_GAIN,
@@ -352,7 +352,7 @@ bool IPAIPU3::validateSensorControls()
};
for (auto c : ctrls) {
- if (sensorCtrls_.find(c) == sensorCtrls_.end()) {
+ if (sensorCtrls.find(c) == sensorCtrls.end()) {
LOG(IPAIPU3, Error) << "Unable to find sensor control "
<< utils::hex(c);
return false;
@@ -482,28 +482,17 @@ void IPAIPU3::updateSessionConfiguration(const IPAConfigInfo &configInfo)
int IPAIPU3::configure(const IPAConfigInfo &configInfo,
ControlInfoMap *ipaControls)
{
- if (configInfo.sensorControls.empty()) {
- LOG(IPAIPU3, Error) << "No sensor controls provided";
- return -ENODATA;
+ if (!validateSensorControls(configInfo.sensorControls)) {
+ LOG(IPAIPU3, Error) << "Sensor control validation failed.";
+ return -EINVAL;
}
+ sensorCtrls_ = configInfo.sensorControls;
sensorInfo_ = configInfo.sensorInfo;
-
lensCtrls_ = configInfo.lensControls;
- /*
- * Compute the sensor V4L2 controls to be used by the algorithms and
- * to be set on the sensor.
- */
- sensorCtrls_ = configInfo.sensorControls;
-
calculateBdsGrid(configInfo.bdsOutputSize);
- if (!validateSensorControls()) {
- LOG(IPAIPU3, Error) << "Sensor control validation failed.";
- return -EINVAL;
- }
-
/* Update the camera controls using the new sensor settings. */
updateControls(sensorInfo_, sensorCtrls_, ipaControls);
--
2.37.2
More information about the libcamera-devel
mailing list