[v2] ipa: rpi: Fix bug in AfState reporting
diff mbox series

Message ID 20250708092239.1589-1-nick.hollinghurst@raspberrypi.com
State Accepted
Commit e6fb24ffdb3efb66829a8b0a8ce5628e4552ee30
Headers show
Series
  • [v2] ipa: rpi: Fix bug in AfState reporting
Related show

Commit Message

Nick Hollinghurst July 8, 2025, 9:22 a.m. UTC
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: ea5f451c5660 ("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>
---
 src/ipa/rpi/controller/rpi/af.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/rpi/controller/rpi/af.cpp b/src/ipa/rpi/controller/rpi/af.cpp
index eaaca4bc..26e59930 100644
--- a/src/ipa/rpi/controller/rpi/af.cpp
+++ b/src/ipa/rpi/controller/rpi/af.cpp
@@ -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();
+			}
 		}
 	}
 }