aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2021-11-03 21:55:42 +0000
committerWarner Losh <imp@FreeBSD.org>2021-11-03 22:03:51 +0000
commit2533eca1c2b9d561c42d28bcb6f1c1c35562fbcc (patch)
tree96825acd4b4e962f10496a57be58bb630e99aaea
parent072d5b98c4318e20248a6fbea4a5ca7c96992cac (diff)
downloadsrc-2533eca1c2b9.tar.gz
src-2533eca1c2b9.zip
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
-rw-r--r--sys/dev/vt/vt.h2
-rw-r--r--sys/dev/vt/vt_core.c13
2 files changed, 14 insertions, 1 deletions
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;
}
}