mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 07:19:45 +03:00
libcamera: camera_sensor: Only access V4L_CID_HBLANK if existing
Correct a crash in CameraSensor::init() when trying to set the V4L2_CID_HBLANK control on sensor not implementing this control. The HBLANK sensor not being mandatory for non-RAW sensors, it can happen that the sensor does not expose this control. Perform check against availability of the control prior to usage in order to avoid the crash. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
34b248c88f
commit
882d04d740
1 changed files with 11 additions and 9 deletions
|
@ -197,17 +197,19 @@ int CameraSensor::init()
|
|||
* \todo The control API ought to have a flag to specify if a control
|
||||
* is read-only which could be used below.
|
||||
*/
|
||||
const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);
|
||||
const int32_t hblankMin = hblank.min().get<int32_t>();
|
||||
const int32_t hblankMax = hblank.max().get<int32_t>();
|
||||
if (ctrls.infoMap()->find(V4L2_CID_HBLANK) != ctrls.infoMap()->end()) {
|
||||
const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);
|
||||
const int32_t hblankMin = hblank.min().get<int32_t>();
|
||||
const int32_t hblankMax = hblank.max().get<int32_t>();
|
||||
|
||||
if (hblankMin != hblankMax) {
|
||||
ControlList ctrl(subdev_->controls());
|
||||
if (hblankMin != hblankMax) {
|
||||
ControlList ctrl(subdev_->controls());
|
||||
|
||||
ctrl.set(V4L2_CID_HBLANK, hblankMin);
|
||||
ret = subdev_->setControls(&ctrl);
|
||||
if (ret)
|
||||
return ret;
|
||||
ctrl.set(V4L2_CID_HBLANK, hblankMin);
|
||||
ret = subdev_->setControls(&ctrl);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue