summaryrefslogtreecommitdiff
path: root/util/spkmodem_decode
AgeCommit message (Collapse)Author
17 hoursutil/spkmodem-decode: clarify frame count on checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/spkmodem-decode: static assertsLeah Rowe
assert integer sizes, important in this program because we make several implicit assumptions about word sizes, and integers need to be of a certain size. Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/spkmodem-decode: annotate prototypesLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
17 hoursutil/spkmodem-decode: rename function for clarityLeah Rowe
collect_separator should be select_separator, to bring it in line with select_low_tone this just makes the code a bit easier to read Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/spkmodem-decode: tidy up indentationLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursfix typo in commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/spkmodem-decode: fix 3-frame timeoutLeah Rowe
i accidentally left this reset here during a previous refactor. Signed-off-by: Leah Rowe <leah@libreboot.org>
18 hoursutil/spkmodem-decode: rename auto_detect_toneLeah Rowe
auto seems redundant. detect implies auto. Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursspkmodem-decode: learn tone per frame, not sampleLeah Rowe
the fir filter produces stable frequencies per frame, but learning per sample (within a frame) means we record the same value roughly 240 times. here, we are syncing up at just the right moment instead, and only at that moment, this increasing both performance and reliability. Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursspkmodem-decode: fix learn_samples incrementLeah Rowe
oops!!! another mistake during refactoring. right now it doesn't increment before being checked, so learning can go forever in an infinite loop Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursspkmodem-decode: don't dump learn_samples in silence checkLeah Rowe
oops Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/spkmodem-decode: split up auto_detect_toneLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/spkmodem-decode: separate silence checkLeah Rowe
i conflated two separate tests in a previous change. the silence check was defeated by still checking f alongside it, which would be set, thus satisfying the condition, and proceeding, which defeats the purpose of the silence check (ignore false signal that is actually noise) - so in the original patch that i wrote, the extra checks actually do nothing. this patch fixes that, and makes the logic a bit clearer. Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/spkmodem-decode: don't run decode in col_sep_toneLeah Rowe
otherwise, it runs twice Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/spkmodem-decode: guard against silence in tone-detectLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/spkmodem-decode: split up handle_audio()Leah Rowe
this enables the separated code to have reduced indentation Signed-off-by: Leah Rowe <leah@libreboot.org>
19 hoursutil/spkmodem-decode: also auto-detect separatorLeah Rowe
the tone detection currently only tracks data, not the separator. track both instead, for improved detection reliability. e.g. separator tone ≈ 9 data low tone ≈ 18 data high tone ≈ 24 two fir windows produce e.g. freq data 9 sep 0 then 18, 9 then 24, 9 18, 9 so we take min(data, separator) that gives 9,9,9,9 now we have the separator cluster however, if both windows are active during transitions, you can also capture the higher clusters, which would allow freq_max to grow so when you learn e.g.: freq min = 9 freq max 24 then the learned threshold would be: (9 + 24) / 2 = 16 and now you know how to separate the tones fir already suppresses noise so the pulse should be reliable. so freq/sep only go non-zero when an actual tone exists this should now result in being able to sync with spkmodem encoders with no prior knowledge of the correct tone frequences. we just use maths. Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/spkmodem-decode: simplify valid_signalLeah Rowe
since we have auto-detection now, we only need to know that two signals exist, not that they are valid, since the auto-detection now handles validation and fallback. Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/spkmodem-decode: automatic tone detectionLeah Rowe
a continuation of the previous patch. this waits for currently one second, before defaulting to the hardcoded value. otherwise, it tries to use whatever timing it gets automatically. this way, the program should now reconfigure its own timing, without intervention by the user, if the timing differs from sensible defaults. this is because spkmodem is implementation-defined; it's just however coreboot and/or GRUB happen to set it up, and on the hardware in question. Signed-off-by: Leah Rowe <leah@libreboot.org>
20 hoursutil/spkmodem-decode: automatic tone calibrationLeah Rowe
current logic is hardcoded, as in the original spkmodem-recv. with this change, small differences are observed and averaged, then the detection thresholds are adjusted accordingly. the existing macros serve as a baseline, but real signals differ. with this change, we therefore account for possible drift in timings, which can change in real-time; the old code could possibly get out of sync beccause of that, which may have resulted in corrupt characters on the screen. this change therefore should make the output a bit more stable. the detection window is continually adjusted, so that the output timings don't drift. the tolerances are automatically adjusted based on base timings (see new define in patch) Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil-spkmodem-decode: tidy up print_statsLeah Rowe
make the frequencies clearer in printf Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/spkmodem-decode: do getopt firstLeah Rowe
much cleaner. do it right after zero-init memset. Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/spkmodem-decode: init argv0 before pledgeLeah Rowe
otherwise, it'll be empty/undefined Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/spkmodem-decode: frequency meter in debugLeah Rowe
useful timing now displayed Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursutil/spkmodem-recv: reset char precisely on timeoutLeah Rowe
instead of when it goes above, do it precisely on the timeout. otherwise, if by sheer chance the signal pauses and we reset the byte - sure, ok, but it's a bit tight and we run the risk of advancing another frame, depending on the timing. this is a minor edge case, probably rarely ever triggered in practise. Signed-off-by: Leah Rowe <leah@libreboot.org>
21 hoursrename util/spkmodem-recv to spkmodem-decodeLeah Rowe
it's no longer resembling the original util at all, so a rename seems indicated. yes. Signed-off-by: Leah Rowe <leah@libreboot.org>