Module Name:    src
Committed By:   isaki
Date:           Sat May  4 06:13:47 UTC 2019

Modified Files:
        src/sys/arch/arm/iomd [isaki-audio2]: vidcaudio.c
        src/sys/dev [isaki-audio2]: files.audio spkr_audio.c
Added Files:
        src/sys/dev/audio [isaki-audio2]: audiobell.c audiobellvar.h
Removed Files:
        src/sys/dev [isaki-audio2]: audiobell.c audiobellvar.h

Log Message:
Move dev/audiobell* -> dev/audio/audiobell*.


To generate a diff of this commit:
cvs rdiff -u -r1.57.2.1 -r1.57.2.2 src/sys/arch/arm/iomd/vidcaudio.c
cvs rdiff -u -r1.26.2.1 -r0 src/sys/dev/audiobell.c
cvs rdiff -u -r1.9 -r0 src/sys/dev/audiobellvar.h
cvs rdiff -u -r1.11.16.2 -r1.11.16.3 src/sys/dev/files.audio
cvs rdiff -u -r1.6.12.1 -r1.6.12.2 src/sys/dev/spkr_audio.c
cvs rdiff -u -r0 -r1.1.2.1 src/sys/dev/audio/audiobell.c \
    src/sys/dev/audio/audiobellvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/iomd/vidcaudio.c
diff -u src/sys/arch/arm/iomd/vidcaudio.c:1.57.2.1 src/sys/arch/arm/iomd/vidcaudio.c:1.57.2.2
--- src/sys/arch/arm/iomd/vidcaudio.c:1.57.2.1	Sun Apr 21 09:12:34 2019
+++ src/sys/arch/arm/iomd/vidcaudio.c	Sat May  4 06:13:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vidcaudio.c,v 1.57.2.1 2019/04/21 09:12:34 isaki Exp $	*/
+/*	$NetBSD: vidcaudio.c,v 1.57.2.2 2019/05/04 06:13:46 isaki Exp $	*/
 
 /*
  * Copyright (c) 1995 Melvin Tang-Richardson
@@ -65,7 +65,7 @@
 
 #include <sys/param.h>	/* proc.h */
 
-__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.57.2.1 2019/04/21 09:12:34 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.57.2.2 2019/05/04 06:13:46 isaki Exp $");
 
 #include <sys/audioio.h>
 #include <sys/conf.h>   /* autoconfig functions */
@@ -78,7 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,
 #include <uvm/uvm_extern.h>
 
 #include <dev/audio_if.h>
-#include <dev/audiobellvar.h>
+#include <dev/audio/audiobellvar.h>
 #include <dev/audio/mulaw.h>
 
 #include <machine/intr.h>

Index: src/sys/dev/files.audio
diff -u src/sys/dev/files.audio:1.11.16.2 src/sys/dev/files.audio:1.11.16.3
--- src/sys/dev/files.audio:1.11.16.2	Fri May  3 05:43:46 2019
+++ src/sys/dev/files.audio	Sat May  4 06:13:46 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.audio,v 1.11.16.2 2019/05/03 05:43:46 isaki Exp $
+#	$NetBSD: files.audio,v 1.11.16.3 2019/05/04 06:13:46 isaki Exp $
 
 define	audiobus	{ }
 define	midibus		{ }
@@ -19,7 +19,7 @@ define	audiobell
 file	dev/audio/alaw.c		audio
 file	dev/audio/linear.c		audio
 file	dev/audio/audio.c		audio			needs-flag
-file	dev/audiobell.c			spkr_audio		needs-flag
+file	dev/audio/audiobell.c		spkr_audio		needs-flag
 file	dev/audio/mulaw.c		audio
 file	dev/midi.c			midi			needs-flag
 file	dev/midictl.c			midisyn

Index: src/sys/dev/spkr_audio.c
diff -u src/sys/dev/spkr_audio.c:1.6.12.1 src/sys/dev/spkr_audio.c:1.6.12.2
--- src/sys/dev/spkr_audio.c:1.6.12.1	Fri May  3 06:19:42 2019
+++ src/sys/dev/spkr_audio.c	Sat May  4 06:13:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: spkr_audio.c,v 1.6.12.1 2019/05/03 06:19:42 isaki Exp $	*/
+/*	$NetBSD: spkr_audio.c,v 1.6.12.2 2019/05/04 06:13:46 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.6.12.1 2019/05/03 06:19:42 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.6.12.2 2019/05/04 06:13:46 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: spkr_audio.c
 #include <sys/sysctl.h>
 #include <dev/audio_if.h>
 
-#include <dev/audiobellvar.h>
+#include <dev/audio/audiobellvar.h>
 
 #include <dev/spkrvar.h>
 #include <dev/spkrio.h>

Added files:

Index: src/sys/dev/audio/audiobell.c
diff -u /dev/null src/sys/dev/audio/audiobell.c:1.1.2.1
--- /dev/null	Sat May  4 06:13:47 2019
+++ src/sys/dev/audio/audiobell.c	Sat May  4 06:13:47 2019
@@ -0,0 +1,149 @@
+/*	$NetBSD: audiobell.c,v 1.1.2.1 2019/05/04 06:13:47 isaki Exp $	*/
+
+/*
+ * Copyright (c) 1999 Richard Earnshaw
+ * Copyright (c) 2004 Ben Harris
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the RiscBSD team.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+__KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.1.2.1 2019/05/04 06:13:47 isaki Exp $");
+
+#include <sys/audioio.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/systm.h>
+#include <sys/uio.h>
+
+#include <dev/audio_if.h>
+#include <dev/audio/audiovar.h>
+#include <dev/audio/audiodef.h>
+#include <dev/audio/audiobellvar.h>
+
+/* 44.1 kHz should reduce hum at higher pitches. */
+#define BELL_SAMPLE_RATE	44100
+
+/*
+ * dev is a device_t for the audio device to use.
+ * pitch is the pitch of the bell in Hz,
+ * period is the length in ms,
+ * volume is the amplitude in % of max,
+ * poll is no longer used.
+ */
+void
+audiobell(void *dev, u_int pitch, u_int period, u_int volume, int poll)
+{
+	dev_t audio;
+	int16_t *buf;
+	struct audiobell_arg bellarg;
+	audio_file_t *file;
+	audio_track_t *ptrack;
+	struct uio auio;
+	struct iovec aiov;
+	int i;
+	int remaincount;
+	int remainlen;
+	int wave1count;
+	int wave1len;
+	int len;
+	int16_t vol;
+
+	KASSERT(volume <= 100);
+
+	/* The audio system isn't built for polling. */
+	if (poll)
+		return;
+
+	/* Limit the pitch from 20Hz to Nyquist frequency. */
+	if (pitch > BELL_SAMPLE_RATE / 2)
+		pitch = BELL_SAMPLE_RATE;
+	if (pitch < 20)
+		pitch = 20;
+
+	buf = NULL;
+	audio = AUDIO_DEVICE | device_unit((device_t)dev);
+
+	memset(&bellarg, 0, sizeof(bellarg));
+	bellarg.encoding = AUDIO_ENCODING_SLINEAR_NE;
+	bellarg.precision = 16;
+	bellarg.channels = 1;
+	bellarg.sample_rate = BELL_SAMPLE_RATE;
+
+	/* If not configured, we can't beep. */
+	if (audiobellopen(audio, &bellarg) != 0)
+		return;
+
+	file = bellarg.file;
+	ptrack = file->ptrack;
+
+	/* msec to sample count. */
+	remaincount = period * BELL_SAMPLE_RATE / 1000;
+	remainlen = remaincount * sizeof(int16_t);
+
+	wave1count = BELL_SAMPLE_RATE / pitch;
+	wave1len = wave1count * sizeof(int16_t);
+
+	buf = malloc(wave1len, M_TEMP, M_WAITOK);
+	if (buf == NULL)
+		goto out;
+
+	/* Generate single square wave.  It's enough to beep. */
+	vol = 32767 * volume / 100;
+	for (i = 0; i < wave1count / 2; i++) {
+		buf[i] = vol;
+	}
+	vol = -vol;
+	for (; i < wave1count; i++) {
+		buf[i] = vol;
+	}
+
+	/* Write while paused to avoid begin inserted silence. */
+	ptrack->is_pause = true;
+	for (; remainlen > 0; remainlen -= wave1len) {
+		len = uimin(remainlen, wave1len);
+		aiov.iov_base = (void *)buf;
+		aiov.iov_len = len;
+		auio.uio_iov = &aiov;
+		auio.uio_iovcnt = 1;
+		auio.uio_offset = 0;
+		auio.uio_resid = len;
+		auio.uio_rw = UIO_WRITE;
+		UIO_SETUP_SYSSPACE(&auio);
+		if (audiobellwrite(file, &auio) != 0)
+			goto out;
+
+		if (ptrack->usrbuf.used >= ptrack->usrbuf_blksize * NBLKHW)
+			ptrack->is_pause = false;
+	}
+	/* Here we go! */
+	ptrack->is_pause = false;
+out:
+	if (buf != NULL)
+		free(buf, M_TEMP);
+	audiobellclose(file);
+}
Index: src/sys/dev/audio/audiobellvar.h
diff -u /dev/null src/sys/dev/audio/audiobellvar.h:1.1.2.1
--- /dev/null	Sat May  4 06:13:47 2019
+++ src/sys/dev/audio/audiobellvar.h	Sat May  4 06:13:47 2019
@@ -0,0 +1,41 @@
+/*	$NetBSD: audiobellvar.h,v 1.1.2.1 2019/05/04 06:13:47 isaki Exp $	*/
+
+/*-
+ * Copyright (c) 2004 Ben Harris
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * To make a noise, call audiobell(dev, pitch, period, volume, poll).
+ * dev is a device_t for the audio device to use.
+ * pitch is the pitch of the bell in Hz,
+ * period is the length in ms,
+ * volume is the amplitude in % of max,
+ * poll is TRUE if we may not block or use interrupts.
+ *
+ * This function is designed to be passed to pckbd_hookup_bell() and
+ * equivalents.
+ */
+void audiobell(void *, u_int, u_int, u_int, int);

Reply via email to