NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/54243: beeping woes with -current



At Wed, 29 May 2019 00:05:00 +0000 (UTC),
dholland%eecs.harvard.edu@localhost wrote:
> >Description:
> I updated the kernel today and beeps in X, which have been loud and
> obnoxious since nat-audio was merged, are now even worse -- they are
> very loud by default, and also they're now staticky/not rendered
> right, which is quite abrasive.

Please try this commit.

| Committed By:	isaki
| Date:		Wed Jun 26 06:57:45 UTC 2019
| 
| Modified Files:
| 	src/sys/dev/audio: audio.c audiobell.c audiodef.h audiovar.h
| 
| Log Message:
| Improve audiobell (and interfaces with audio).
| - Generate pseudo sine wave if possible.  It may improve timbre.
|   If it cannot represent a sine wave, it falls back to a triangular
|   wave or a rectangular wave.
| - Volume adjustment.
| - Calculate playback frequency based on mixer frequency.
|   Now audiobellopen() initializes playback parameters other than
|   sample_rate, and new audiobellsetrate() sets sample_rate.
| 
| To generate a diff of this commit:
| cvs rdiff -u -r1.20 -r1.21 src/sys/dev/audio/audio.c
| cvs rdiff -u -r1.2 -r1.3 src/sys/dev/audio/audiobell.c
| cvs rdiff -u -r1.5 -r1.6 src/sys/dev/audio/audiodef.h
| cvs rdiff -u -r1.3 -r1.4 src/sys/dev/audio/audiovar.h

> The overt problem is spkr1; I can hear that the PC speaker is also
> beeping but can't hear it clearly over the other, so I can't tell if
> it's also messed up.

Use the following temprary patch to separate the problem.
It adds sysctl hw.wsbell<N>.mute knob.
# I don't have solution about the problem that all spkr* beep
# simultatenously..

--- a/sys/dev/wscons/wsbell.c
+++ b/sys/dev/wscons/wsbell.c
@@ -128,6 +128,7 @@ __KERNEL_RCSID(0, "$NetBSD: wsbell.c,v 1.11 2019/04/18 14:01:28 isaki Exp $");
 #include <sys/systm.h>
 #include <sys/tty.h>
 #include <sys/signalvar.h>
+#include <sys/sysctl.h>
 #include <sys/device.h>
 #include <sys/vnode.h>
 #include <sys/callout.h>
@@ -213,6 +214,7 @@ wsbell_attach(device_t parent, device_t self, void *aux)
 {
 	struct wsbell_softc *sc = device_private(self);
 	struct wsbelldev_attach_args *ap = aux;
+	const struct sysctlnode *node;
 #if NWSMUX > 0
 	int mux, error;
 #endif
@@ -247,6 +249,25 @@ wsbell_attach(device_t parent, device_t self, void *aux)
 	mutex_init(&sc->sc_bellock, MUTEX_DEFAULT, IPL_SCHED);
 	cv_init(&sc->sc_bellcv, "bellcv");
 
+	sc->sc_mute = 0;
+	sysctl_createv(&sc->sc_log, 0, NULL, &node,
+	    0,
+	    CTLTYPE_NODE, device_xname(self),
+	    SYSCTL_DESCR("mute test"),
+	    NULL, 0,
+	    NULL, 0,
+	    CTL_HW,
+	    CTL_CREATE, CTL_EOL);
+
+	if (node != NULL) {
+		sysctl_createv(&sc->sc_log, 0, NULL, NULL,
+		    CTLFLAG_READWRITE,
+		    CTLTYPE_INT, "mute",
+		    SYSCTL_DESCR("mute test"),
+		    NULL, 0, &sc->sc_mute, sizeof(sc->sc_mute),
+		    CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
+	}
+
 	kthread_create(PRI_BIO, KTHREAD_MPSAFE | KTHREAD_MUSTJOIN, NULL,
 	    bell_thread, sc, &sc->sc_bellthread, "%s", device_xname(self));
 }
@@ -315,6 +336,8 @@ wsbell_detach(device_t self, int flags)
 	cv_destroy(&sc->sc_bellcv);
 	mutex_destroy(&sc->sc_bellock);
 
+	sysctl_teardown(&sc->sc_log);
+
 	return (0);
 }
 
@@ -423,6 +446,11 @@ bell_thread(void *arg)
 			kthread_exit(0);
 		}
 
+		if (sc->sc_mute) {
+			mutex_exit(&sc->sc_bellock);
+			continue;
+		}
+
 		tone.frequency = vb->pitch;
 		/*
 		 * period (derived from wskbd) is in msec.
--- a/sys/dev/wscons/wsbellvar.h
+++ b/sys/dev/wscons/wsbellvar.h
@@ -46,6 +46,8 @@ struct wsbell_softc {
 
 	int		sc_refcnt;
 	bool		sc_dying;	/* device is being detached */
+	struct sysctllog *sc_log;
+	int		sc_mute;
 
 	lwp_t		*sc_bellthread;
 	kmutex_t	sc_bellock;

---
Tetsuya Isaki <isaki%pastel-flower.jp@localhost / isaki%NetBSD.org@localhost>


Home | Main Index | Thread Index | Old Index