aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2021-11-03 21:55:55 +0000
committerWarner Losh <imp@FreeBSD.org>2021-11-03 22:03:51 +0000
commitba48d52ca6c867559156dd916631f9ac47abe80f (patch)
tree9351e5e102c155eb76352836c1cd218ef7a1b15d
parent4ac3d08a9693c27c1bd2ddd67b2808ac9e18f4c5 (diff)
downloadsrc-ba48d52ca6c867559156dd916631f9ac47abe80f.tar.gz
src-ba48d52ca6c867559156dd916631f9ac47abe80f.zip
vt: Fix frequency calcuation for bell
386BSD provided a MD function sysbeep. This took two arguments (pitch and period). Pitch was jammed into the PIT's divisor directly (which means the argument was expected to sound a tone at '1193182 / pitch' Hz). FreeBSD inherited this interface. In commit e46598588587 (svn 177642, Mar 26 2008), phk changed this function to take a tone to sound in hz. He converted all in-tree instances of 1193182 / hz to just hz (and kept the few misguided folks that passed hz directly unchanged -- this was part of what motivated the change). He converted the places where we pre-computed the 8254 divisor from being pitch to 1193182 / pitch (since that converts the divisor to the frequency and the interfaces that were exposed to userland exposed it in these units in places, continuing the tradition inherited from SCO System V/386 Unix in spots). In 2009, Ed Shouten was contracted by the FreeBSD Foundation to write / finish newcons. This work was done in perforce and was imported into subversion in user/ed/newcons in revision 199072 (https://svnweb.freebsd.org/base?view=revision&revision=199072) which was later imported into FreeBSD by ray@ (Aleksandr Rybalko). From that earliest import into svn import to this date, we ring the bell with: sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION); where VT_BELLPITCH was defined to be 800. This results in a bell frequency of 1491Hz, more or less today. This is similar to the frequency that syscons and pcvt used (1493Hz and 1500Hz respectively). This in turn was inherited from 386BSD, it seems, which used the hard coded value 0x31b which is 795 -> 1500Hz. This '800' was intended to be the bell tone (eg 800Hz) and this interface was one that wasn't converted. The most common terminal prior to the rise of PCs was the VT100, which had an approximately 800Hz bell. Ed Shouten has confirmed that the original intent was 800Hz and changing this was overlooked after the change to -current was made. This restors that original intent and makes the bell less obnoxious in the process. Reviewed by: des, adrian Differential Revision: https://reviews.freebsd.org/D32594 Sponsored by: Netflix
-rw-r--r--sys/dev/vt/vt_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index 38efd1e5501c..06f5827078ca 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -121,7 +121,7 @@ const struct terminal_class vt_termclass = {
/* Bell pitch/duration. */
#define VT_BELLDURATION (SBT_1S / 20)
-#define VT_BELLPITCH (1193182 / 800) /* Approx 1491Hz */
+#define VT_BELLPITCH 800
#define VT_UNIT(vw) ((vw)->vw_device->vd_unit * VT_MAXWINDOWS + \
(vw)->vw_number)