spkmodem-decode: fix single-tone learning bug

enforce at least two tones. this mitigates the
chance of random noise being treated as a real
tone, and reduces the chance of broken
thresholds versus freq min/max e.g.
freq min 31, max 32 and threshold 31

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-13 01:45:17 +00:00
parent 05f59ac7c6
commit aada4848c1

View File

@@ -571,6 +571,14 @@ detect_tone(struct decoder_state *st)
if (st->learn_frames != LEARN_FRAMES)
return;
/*
* If the observed frequencies are too close,
* learning likely failed (only one tone seen).
* Keep the default threshold.
*/
if (st->freq_max - st->freq_min < 2)
return;
st->freq_threshold =
(st->freq_min + st->freq_max) / 2;