[libcamera-devel,2/2] ipa: ipu3: Ensure controls exists in updateSessionConfiguration()
diff mbox series

Message ID 20220303155322.525946-1-umang.jain@ideasonboard.com
State Superseded
Headers show
Series
  • [libcamera-devel,v2] ipa: ipu3: Consolidate querying of exposure and gain limits
Related show

Commit Message

Umang Jain March 3, 2022, 3:53 p.m. UTC
Add a control-not-found error checking for the controls being
queried in IPAIPU3::updateSessionConfiguration().

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/ipa/ipu3/ipu3.cpp | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 7b190217..6e4aa674 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -180,16 +180,31 @@  private:
  */
 void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)
 {
-	const ControlInfo vBlank = sensorControls.find(V4L2_CID_VBLANK)->second;
-	context_.configuration.sensor.defVBlank = vBlank.def().get<int32_t>();
+	const auto itVBlank = sensorControls.find(V4L2_CID_VBLANK);
+	if (itVBlank == sensorControls.end()) {
+		LOG(IPAIPU3, Error) << "Can't find vblank control";
+		return;
+	}
 
-	const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;
-	int32_t minExposure = v4l2Exposure.min().get<int32_t>();
-	int32_t maxExposure = v4l2Exposure.max().get<int32_t>();
+	context_.configuration.sensor.defVBlank = itVBlank->second.def().get<int32_t>();
+
+	const auto itExp = sensorControls.find(V4L2_CID_EXPOSURE);
+	if (itExp == sensorControls.end()) {
+		LOG(IPAIPU3, Error) << "Can't find exposure control";
+		return;
+	}
+
+	int32_t minExposure = itExp->second.min().get<int32_t>();
+	int32_t maxExposure = itExp->second.max().get<int32_t>();
+
+	const auto itGain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN);
+	if (itGain == sensorControls.end()) {
+		LOG(IPAIPU3, Error) << "Can't find analogue gain control";
+		return;
+	}
 
-	const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;
-	int32_t minGain = v4l2Gain.min().get<int32_t>();
-	int32_t maxGain = v4l2Gain.max().get<int32_t>();
+	int32_t minGain = itGain->second.min().get<int32_t>();
+	int32_t maxGain = itGain->second.max().get<int32_t>();
 
 	/*
 	 * When the AGC computes the new exposure values for a frame, it needs