diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-13 01:45:17 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-26 06:59:40 +0000 |
| commit | fe6da7a238796983a139b2421d306d4dc46d5450 (patch) | |
| tree | dfce1dac9ffa824ef0b19093aacd66a0ce01ea82 /util/spkmodem_decode | |
| parent | 9e94cc017a79b33a6907053b8893aeb2dcb52483 (diff) | |
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>
Diffstat (limited to 'util/spkmodem_decode')
| -rw-r--r-- | util/spkmodem_decode/spkmodem-decode.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/spkmodem_decode/spkmodem-decode.c b/util/spkmodem_decode/spkmodem-decode.c index 7d45c3b3..92bacb20 100644 --- a/util/spkmodem_decode/spkmodem-decode.c +++ b/util/spkmodem_decode/spkmodem-decode.c @@ -575,6 +575,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; |
