[Bug 281713] kbdcontrol -b to set bell frequency is inverted vs sc

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 25 Sep 2024 15:06:19 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281713

            Bug ID: 281713
           Summary: kbdcontrol -b to set bell frequency is inverted vs sc
           Product: Base System
           Version: 14.1-STABLE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: divVerent@gmail.com

Note: this bug kinda implies that
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204837 has been "fixed" - the
command definitely does something now, just not the right thing.

Running these shell commands in order:

```
kbdcontrol -b 300.440
sleep 0.1
printf '\a'
sleep 0.4
kbdcontrol -b 300.554
sleep 0.1
printf '\a'
sleep 0.4
kbdcontrol -b 300.659
sleep 0.1
printf '\a'
```

should play an increasing chords, as the frequencies are the ones of the notes
A, C# and E.

And it does this fine when booting with `kern.vty=sc`.

However, it actually plays a decreasing, and too high pitched, chord when in
`vt`! According to audacity, the frequencies actually played are 2659Hz, 2149Hz
and 1804Hz.

This can be repro'd right on the "disc1" image.

There is a frequency division here in `kbdcontrol`:

https://github.com/freebsd/freebsd-src/blob/main/usr.sbin/kbdcontrol/kbdcontrol.c#L1042

Removing this division statement makes it sound exactly as it should. And in
fact, when multiplying intended and measured frequencies, I get 1169960,
1190546 and 1188836, respectively - all really close to the magic constant in
that division.

Thus, I suspect one of two things is the case:

- vt intentionally changed the meaning of the `ESC [ = pitch ; duration B`
escape sequence to now express pitch in Hertz, not 8254 timer ticks, but it was
forgotten to make `kbdcontrol` detect whether it's running on vt or syscons and
respond accordingly.
- vt accidentally changed the meaning of the sequence, and should get a fix
added to match up with syscons.

-- 
You are receiving this mail because:
You are the assignee for the bug.