Date: Fri, 19 Nov 2021 04:53:30 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 534fb4b8aec0 - stable/13 - vt(4): Connect to teken's TP_SETBELLPD Message-ID: <202111190453.1AJ4rU16061288@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=534fb4b8aec07d97bbd414a390fe1a6c5b169af8 commit 534fb4b8aec07d97bbd414a390fe1a6c5b169af8 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2021-11-19 04:51:13 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-11-19 04:52:22 +0000 vt(4): Connect to teken's TP_SETBELLPD Add the glue needed to listen to TP_SETBELLPD which teken uses to inform its client drivers about the results of parsing \e[=<pitch>;<duration>B. It converts these to a Hz value for the tone/pitch of the bell and a duration in ms. There's some loss of precision because <pitch> in the escape seuquence is defined to be (1193182 / pitch) Hz and <duration> is in 10ms units. Also note that kbdcontrol also parses 'off' but then doesn't send the proper escape sequence, leading me to wonder if that's another bug since teken appears to parse that sequence properly and I've added code here to treat that as the same as quiet or disabled. In general, Hz from 100 to 2000 is good. Outside that range is possible, but even at 100Hz the square wave is starting to sound bad and above 2000Hz the speaker may not respond. Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D32620 (cherry picked from commit 2533eca1c2b9d561c42d28bcb6f1c1c35562fbcc) --- sys/dev/vt/vt.h | 2 ++ sys/dev/vt/vt_core.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 2d671d692384..ad3cb310b510 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -309,6 +309,8 @@ struct vt_window { struct vt_mode vw_smode; /* switch mode */ struct callout vw_proc_dead_timer; struct vt_window *vw_switch_to; + int vw_bell_pitch; /* (?) Bell pitch */ + sbintime_t vw_bell_duration; /* (?) Bell duration */ }; #define VT_AUTO 0 /* switching is automatic */ diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 708e5ba70f15..ebcb4fc8f103 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -258,6 +258,8 @@ static struct vt_window vt_conswindow = { .vw_terminal = &vt_consterm, .vw_kbdmode = K_XLATE, .vw_grabbed = 0, + .vw_bell_pitch = VT_BELLPITCH, + .vw_bell_duration = VT_BELLDURATION, }; struct terminal vt_consterm = { .tm_class = &vt_termclass, @@ -1101,7 +1103,11 @@ vtterm_bell(struct terminal *tm) if (vd->vd_flags & VDF_QUIET_BELL) return; - sysbeep(VT_BELLPITCH, VT_BELLDURATION); + if (vw->vw_bell_pitch == 0 || + vw->vw_bell_duration == 0) + return; + + sysbeep(vw->vw_bell_pitch, vw->vw_bell_duration); } static void @@ -1178,6 +1184,11 @@ vtterm_param(struct terminal *tm, int cmd, unsigned int arg) case TP_MOUSE: vw->vw_mouse_level = arg; break; + case TP_SETBELLPD: + vw->vw_bell_pitch = TP_SETBELLPD_PITCH(arg); + vw->vw_bell_duration = + TICKS_2_MSEC(TP_SETBELLPD_DURATION(arg)) * SBT_1MS; + break; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111190453.1AJ4rU16061288>