mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-25 21:39:03 +02:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user