diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-13 01:45:17 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-13 01:45:17 +0000 |
| commit | aada4848c15e14560df7b652dcbdd447be094ee8 (patch) | |
| tree | 48c256c33ea5f40df021130ee00078903d811d0b | |
| parent | 05f59ac7c62b15f61f191cb4a7022f44667f2f5f (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>
| -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 af60f997..a1a197bc 100644 --- a/util/spkmodem_decode/spkmodem-decode.c +++ b/util/spkmodem_decode/spkmodem-decode.c @@ -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; |
