ipa: rpi: Fix bug in AfState reporting

A previous change introduced a bug in which it reported AfStateIdle
when idle in Auto mode, when it should continue to report the most
recent AF cycle's outcome (AfStateFocused or AfStateFailed).

Also fix the Pause method so it won't reset state to AfStateIdle
when paused in Continuous AF mode (to match documented behaviour).

Fixes: ea5f451c56 ("ipa: rpi: controller: AutoFocus bidirectional scanning")
Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Nick Hollinghurst 2025-07-08 10:22:39 +01:00 committed by Kieran Bingham
parent 525325440b
commit e6fb24ffdb

View file

@ -810,10 +810,10 @@ void Af::prepare(Metadata *imageMetadata)
else
status.pauseState = AfPauseState::Running;
if (scanState_ == ScanState::Idle)
status.state = AfState::Idle;
else if (mode_ == AfModeAuto)
if (mode_ == AfModeAuto && scanState_ != ScanState::Idle)
status.state = AfState::Scanning;
else if (mode_ == AfModeManual)
status.state = AfState::Idle;
else
status.state = reportState_;
status.lensSetting = initted_ ? std::optional<int>(cfg_.map.eval(fsmooth_))
@ -954,8 +954,10 @@ void Af::pause(AfAlgorithm::AfPause pause)
scanState_ = ScanState::Trigger;
} else if (pause != AfPauseResume && !pauseFlag_) {
pauseFlag_ = true;
if (pause == AfPauseImmediate || scanState_ < ScanState::Coarse1)
goIdle();
if (pause == AfPauseImmediate || scanState_ < ScanState::Coarse1) {
scanState_ = ScanState::Idle;
scanData_.clear();
}
}
}
}