From nobody Fri Nov 19 04:53:30 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7FE5E1897FDA; Fri, 19 Nov 2021 04:53:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HwPSX26Bfz4Tjf; Fri, 19 Nov 2021 04:53:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ACFFE226A4; Fri, 19 Nov 2021 04:53:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AJ4rUoX061289; Fri, 19 Nov 2021 04:53:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AJ4rU16061288; Fri, 19 Nov 2021 04:53:30 GMT (envelope-from git) Date: Fri, 19 Nov 2021 04:53:30 GMT Message-Id: <202111190453.1AJ4rU16061288@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 534fb4b8aec0 - stable/13 - vt(4): Connect to teken's TP_SETBELLPD List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 534fb4b8aec07d97bbd414a390fe1a6c5b169af8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=534fb4b8aec07d97bbd414a390fe1a6c5b169af8 commit 534fb4b8aec07d97bbd414a390fe1a6c5b169af8 Author: Warner Losh AuthorDate: 2021-11-19 04:51:13 +0000 Commit: Warner Losh 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[=;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 in the escape seuquence is defined to be (1193182 / pitch) Hz and 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; } }