Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Nov 2021 22:04:17 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 2533eca1c2b9 - main - vt(4): Connect to teken's TP_SETBELLPD
Message-ID:  <202111032204.1A3M4HtB066334@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=2533eca1c2b9d561c42d28bcb6f1c1c35562fbcc

commit 2533eca1c2b9d561c42d28bcb6f1c1c35562fbcc
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-11-03 21:55:42 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-11-03 22:03:51 +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
---
 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 8a74fd97a4e0..5ba64388bd27 100644
--- a/sys/dev/vt/vt.h
+++ b/sys/dev/vt/vt.h
@@ -308,6 +308,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 567cdd2890d5..a197c8e8be68 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -257,6 +257,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,
@@ -1100,7 +1102,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
@@ -1177,6 +1183,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?202111032204.1A3M4HtB066334>