CVS commit: src/sys/dev/audio

2020-02-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Feb 23 04:24:56 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Improve error handling around audio_hw_probe().
It was difficult to return multiple errors.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.54 src/sys/dev/audio/audio.c:1.55
--- src/sys/dev/audio/audio.c:1.54	Sun Feb 23 04:02:46 2020
+++ src/sys/dev/audio/audio.c	Sun Feb 23 04:24:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.54 2020/02/23 04:02:46 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.55 2020/02/23 04:24:56 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.54 2020/02/23 04:02:46 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.55 2020/02/23 04:24:56 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -558,9 +558,7 @@ static int audio_mixers_init(struct audi
 	const audio_format2_t *, const audio_format2_t *,
 	const audio_filter_reg_t *, const audio_filter_reg_t *);
 static int audio_select_freq(const struct audio_format *);
-static int audio_hw_probe(struct audio_softc *, int, int *,
-	audio_format2_t *, audio_format2_t *);
-static int audio_hw_probe_fmt(struct audio_softc *, audio_format2_t *, int);
+static int audio_hw_probe(struct audio_softc *, audio_format2_t *, int);
 static int audio_hw_validate_format(struct audio_softc *, int,
 	const audio_format2_t *);
 static int audio_mixers_set_format(struct audio_softc *,
@@ -940,21 +938,46 @@ audioattach(device_t parent, device_t se
 	memset(&rhwfmt, 0, sizeof(rhwfmt));
 	memset(&pfil, 0, sizeof(pfil));
 	memset(&rfil, 0, sizeof(rfil));
-	mutex_enter(sc->sc_lock);
-	error = audio_hw_probe(sc, has_indep, &mode, &phwfmt, &rhwfmt);
-	if (error) {
-		mutex_exit(sc->sc_lock);
-		aprint_error_dev(self, "audio_hw_probe failed, "
-		"error = %d\n", error);
-		goto bad;
-	}
-	if (mode == 0) {
-		mutex_exit(sc->sc_lock);
-		aprint_error_dev(self, "audio_hw_probe failed, no mode\n");
-		goto bad;
+	if (has_indep) {
+		int perror, rerror;
+
+		/* On independent devices, probe separately. */
+		perror = audio_hw_probe(sc, &phwfmt, AUMODE_PLAY);
+		rerror = audio_hw_probe(sc, &rhwfmt, AUMODE_RECORD);
+		if (perror && rerror) {
+			aprint_error_dev(self, "audio_hw_probe failed, "
+			"perror = %d, rerror = %d\n", perror, rerror);
+			goto bad;
+		}
+		if (perror) {
+			mode &= ~AUMODE_PLAY;
+			aprint_error_dev(self, "audio_hw_probe failed with "
+			"%d, playback disabled\n", perror);
+		}
+		if (rerror) {
+			mode &= ~AUMODE_RECORD;
+			aprint_error_dev(self, "audio_hw_probe failed with "
+			"%d, capture disabled\n", rerror);
+		}
+	} else {
+		/*
+		 * On non independent devices or uni-directional devices,
+		 * probe once (simultaneously).
+		 */
+		audio_format2_t *fmt = has_playback ? &phwfmt : &rhwfmt;
+		error = audio_hw_probe(sc, fmt, mode);
+		if (error) {
+			aprint_error_dev(self, "audio_hw_probe failed, "
+			"error = %d\n", error);
+			goto bad;
+		}
+		if (has_playback && has_capture)
+			rhwfmt = phwfmt;
 	}
+
 	/* Init hardware. */
 	/* hw_probe() also validates [pr]hwfmt.  */
+	mutex_enter(sc->sc_lock);
 	error = audio_hw_set_format(sc, mode, &phwfmt, &rhwfmt, &pfil, &rfil);
 	if (error) {
 		mutex_exit(sc->sc_lock);
@@ -6045,68 +6068,13 @@ audio_select_freq(const struct audio_for
 }
 
 /*
- * Probe playback and/or recording format (depending on *modep).
- * *modep is an in-out parameter.  It indicates the direction to configure
- * as an argument, and the direction configured is written back as out
- * parameter.
- * If successful, probed hardware format is stored into *phwfmt, *rhwfmt
- * depending on *modep, and return 0.  Otherwise it returns errno.
- * Must be called with sc_lock held.
- */
-static int
-audio_hw_probe(struct audio_softc *sc, int is_indep, int *modep,
-	audio_format2_t *phwfmt, audio_format2_t *rhwfmt)
-{
-	audio_format2_t fmt;
-	int mode;
-	int error = 0;
-
-	KASSERT(mutex_owned(sc->sc_lock));
-
-	mode = *modep;
-	KASSERTMSG((mode & (AUMODE_PLAY | AUMODE_RECORD)) != 0, "mode=0x%x", mode);
-
-	if (is_indep) {
-		int errorp = 0, errorr = 0;
-
-		/* On independent devices, probe separately. */
-		if ((mode & AUMODE_PLAY) != 0) {
-			errorp = audio_hw_probe_fmt(sc, phwfmt, AUMODE_PLAY);
-			if (errorp)
-mode &= ~AUMODE_PLAY;
-		}
-		if ((mode & AUMODE_RECORD) != 0) {
-			errorr = audio_hw_probe_fmt(sc, rhwfmt, AUMODE_RECORD);
-			if (errorr)
-mode &= ~AUMODE_RECORD;
-		}
-
-		/* Return error if both play and record probes failed. */
-		if (errorp && errorr)
-			error = errorp;
-	} else {
-		/* On non independent devices, probe simultaneously. */
-		error = audio_hw_probe_fmt(sc, &fmt, mode);
-		if (er

CVS commit: src

2020-02-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Feb 23 04:02:46 UTC 2020

Modified Files:
src/share/man/man9: audio.9
src/sys/arch/arm/iomd: vidcaudio.c
src/sys/arch/dreamcast/dev/g2: aica.c
src/sys/arch/hpcmips/vr: vraiu.c
src/sys/dev/audio: audio.c
src/sys/dev/ic: pl041.c
src/sys/dev/pad: pad.c

Log Message:
Make start_input/halt_input optional if the driver has no recording,
make start_output/halt_output optional if the driver has no playback.
And remove such never called functions.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/share/man/man9/audio.9
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/arm/iomd/vidcaudio.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/dreamcast/dev/g2/aica.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/hpcmips/vr/vraiu.c
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/pl041.c
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pad/pad.c

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

Modified files:

Index: src/share/man/man9/audio.9
diff -u src/share/man/man9/audio.9:1.56 src/share/man/man9/audio.9:1.57
--- src/share/man/man9/audio.9:1.56	Wed Jun 12 13:53:25 2019
+++ src/share/man/man9/audio.9	Sun Feb 23 04:02:45 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audio.9,v 1.56 2019/06/12 13:53:25 wiz Exp $
+.\"	$NetBSD: audio.9,v 1.57 2020/02/23 04:02:45 isaki Exp $
 .\"
 .\" Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -395,6 +395,7 @@ Calling
 will normally initiate another call to
 .Va start_output .
 Return 0 on success, otherwise an error code.
+This field is optional only if the driver doesn't support playback.
 It is called in the Opened phase.
 .It Dv int start_input(void *hdl, void *block, int blksize,
 .Dv "void (*intr)(void*), void *intrarg)"
@@ -415,18 +416,21 @@ Calling
 will normally initiate another call to
 .Va start_input .
 Return 0 on success, otherwise an error code.
+This field is optional only if the driver doesn't support recording.
 It is called in the Opened phase.
 .It Dv int halt_output(void *hdl)
 is called to abort the output transfer (started by
 .Va start_output )
 in progress.
 Return 0 on success, otherwise an error code.
+This field is optional only if the driver doesn't support playback.
 It is called in the Opened phase.
 .It Dv int halt_input(void *hdl)
 is called to abort the input transfer (started by
 .Va start_input )
 in progress.
 Return 0 on success, otherwise an error code.
+This field is optional only if the driver doesn't support recording,
 It is called in the Opened phase.
 .It Dv int speaker_ctl(void *hdl, int on)
 optional, is called when a half duplex device changes between

Index: src/sys/arch/arm/iomd/vidcaudio.c
diff -u src/sys/arch/arm/iomd/vidcaudio.c:1.59 src/sys/arch/arm/iomd/vidcaudio.c:1.60
--- src/sys/arch/arm/iomd/vidcaudio.c:1.59	Sat Jun  8 08:02:36 2019
+++ src/sys/arch/arm/iomd/vidcaudio.c	Sun Feb 23 04:02:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vidcaudio.c,v 1.59 2019/06/08 08:02:36 isaki Exp $	*/
+/*	$NetBSD: vidcaudio.c,v 1.60 2020/02/23 04:02:45 isaki Exp $	*/
 
 /*
  * Copyright (c) 1995 Melvin Tang-Richardson
@@ -65,7 +65,7 @@
 
 #include 	/* proc.h */
 
-__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.59 2019/06/08 08:02:36 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.60 2020/02/23 04:02:45 isaki Exp $");
 
 #include 
 #include/* autoconfig functions */
@@ -148,10 +148,7 @@ static intvidcaudio_set_format(void 
 static intvidcaudio_round_blocksize(void *, int, int, const audio_params_t *);
 static intvidcaudio_trigger_output(void *, void *, void *, int,
 void (*)(void *), void *, const audio_params_t *);
-static intvidcaudio_trigger_input(void *, void *, void *, int,
-void (*)(void *), void *, const audio_params_t *);
 static intvidcaudio_halt_output(void *);
-static intvidcaudio_halt_input(void *);
 static intvidcaudio_getdev(void *, struct audio_device *);
 static intvidcaudio_set_port(void *, mixer_ctrl_t *);
 static intvidcaudio_get_port(void *, mixer_ctrl_t *);
@@ -171,14 +168,12 @@ static const struct audio_hw_if vidcaudi
 	.set_format		= vidcaudio_set_format,
 	.round_blocksize	= vidcaudio_round_blocksize,
 	.halt_output		= vidcaudio_halt_output,
-	.halt_input		= vidcaudio_halt_input,
 	.getdev			= vidcaudio_getdev,
 	.set_port		= vidcaudio_set_port,
 	.get_port		= vidcaudio_get_port,
 	.query_devinfo		= vidcaudio_query_devinfo,
 	.get_props		= vidcaudio_get_props,
 	.trigger_output		= vidcaudio_trigger_output,
-	.trigger_input		= vidcaudio_trigger_input,
 	.get_locks		= vidcaudio_get_locks,
 };
 
@@ -427,14 +422,6 @@ vidcaudio_trigger_output(void *addr, voi
 }
 
 static int
-vidcaudio_trigger_input(void *addr, void *start, void *end, int blksize,
-void (*intr)(void *), void *arg, const audio_params_t *params)
-{
-
-	return ENODEV;
-}
-
-static int

CVS commit: src/sys/dev

2020-02-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 08:15:09 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c
src/sys/dev/pad: pad.c

Log Message:
Make calling get_props() lockless.
get_props() of all MD drivers now can be called without sc_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.63 -r1.64 src/sys/dev/pad/pad.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.51 src/sys/dev/audio/audio.c:1.52
--- src/sys/dev/audio/audio.c:1.51	Sat Feb 22 08:03:19 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 08:15:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.51 2020/02/22 08:03:19 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.52 2020/02/22 08:15:09 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -121,7 +121,7 @@
  *	allocm 			-	- +	(*1)
  *	freem 			-	- +	(*1)
  *	round_buffersize 	-	x
- *	get_props 		-	x	Called at attach time
+ *	get_props 		-	-	Called at attach time
  *	trigger_output 		x	x +
  *	trigger_input 		x	x +
  *	dev_ioctl 		-	x
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.51 2020/02/22 08:03:19 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.52 2020/02/22 08:15:09 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -886,9 +886,7 @@ audioattach(device_t parent, device_t se
 	sc->sc_am_used = 0;
 	sc->sc_am = NULL;
 
-	mutex_enter(sc->sc_lock);
 	sc->sc_props = hw_if->get_props(sc->hw_hdl);
-	mutex_exit(sc->sc_lock);
 
 	/* MMAP is now supported by upper layer.  */
 	sc->sc_props |= AUDIO_PROP_MMAP;

Index: src/sys/dev/pad/pad.c
diff -u src/sys/dev/pad/pad.c:1.63 src/sys/dev/pad/pad.c:1.64
--- src/sys/dev/pad/pad.c:1.63	Wed Jun 26 12:21:40 2019
+++ src/sys/dev/pad/pad.c	Sat Feb 22 08:15:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.63 2019/06/26 12:21:40 isaki Exp $ */
+/* $NetBSD: pad.c,v 1.64 2020/02/22 08:15:09 isaki Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.63 2019/06/26 12:21:40 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.64 2020/02/22 08:15:09 isaki Exp $");
 
 #include 
 #include 
@@ -795,11 +795,6 @@ pad_query_devinfo(void *opaque, mixer_de
 static int
 pad_get_props(void *opaque)
 {
-	struct pad_softc *sc __diagused;
-
-	sc = (struct pad_softc *)opaque;
-
-	KASSERT(mutex_owned(&sc->sc_lock));
 
 	return AUDIO_PROP_PLAYBACK;
 }



CVS commit: src/sys/dev/audio

2020-02-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 08:03:19 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
On audio_[pr]mixer_halt(), it's better to reset parameters in intr_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.50 src/sys/dev/audio/audio.c:1.51
--- src/sys/dev/audio/audio.c:1.50	Sat Feb 22 08:01:59 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 08:03:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.50 2020/02/22 08:01:59 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.51 2020/02/22 08:03:19 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.50 2020/02/22 08:01:59 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.51 2020/02/22 08:03:19 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -5546,7 +5546,6 @@ audio_pmixer_halt(struct audio_softc *sc
 
 	mutex_enter(sc->sc_intr_lock);
 	error = sc->hw_if->halt_output(sc->hw_hdl);
-	mutex_exit(sc->sc_intr_lock);
 
 	/* Halts anyway even if some error has occurred. */
 	sc->sc_pbusy = false;
@@ -5554,6 +5553,7 @@ audio_pmixer_halt(struct audio_softc *sc
 	sc->sc_pmixer->hwbuf.used = 0;
 	sc->sc_pmixer->mixseq = 0;
 	sc->sc_pmixer->hwseq = 0;
+	mutex_exit(sc->sc_intr_lock);
 
 	return error;
 }
@@ -5576,7 +5576,6 @@ audio_rmixer_halt(struct audio_softc *sc
 
 	mutex_enter(sc->sc_intr_lock);
 	error = sc->hw_if->halt_input(sc->hw_hdl);
-	mutex_exit(sc->sc_intr_lock);
 
 	/* Halts anyway even if some error has occurred. */
 	sc->sc_rbusy = false;
@@ -5584,6 +5583,7 @@ audio_rmixer_halt(struct audio_softc *sc
 	sc->sc_rmixer->hwbuf.used = 0;
 	sc->sc_rmixer->mixseq = 0;
 	sc->sc_rmixer->hwseq = 0;
+	mutex_exit(sc->sc_intr_lock);
 
 	return error;
 }



CVS commit: src/sys/dev/audio

2020-02-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 08:01:59 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Add KASSERTs.  audio_[pr]mixer_start() need exlock.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.49 src/sys/dev/audio/audio.c:1.50
--- src/sys/dev/audio/audio.c:1.49	Sat Feb 22 07:59:47 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 08:01:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.49 2020/02/22 07:59:47 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.50 2020/02/22 08:01:59 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.49 2020/02/22 07:59:47 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.50 2020/02/22 08:01:59 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -4788,7 +4788,7 @@ audio_mixer_destroy(struct audio_softc *
 /*
  * Starts playback mixer.
  * Must be called only if sc_pbusy is false.
- * Must be called with sc_lock held.
+ * Must be called with sc_lock && sc_exlock held.
  * Must not be called from the interrupt context.
  */
 static void
@@ -4798,6 +4798,7 @@ audio_pmixer_start(struct audio_softc *s
 	int minimum;
 
 	KASSERT(mutex_owned(sc->sc_lock));
+	KASSERT(sc->sc_exlock);
 	KASSERT(sc->sc_pbusy == false);
 
 	mutex_enter(sc->sc_intr_lock);
@@ -5290,7 +5291,7 @@ audio_pintr(void *arg)
 /*
  * Starts record mixer.
  * Must be called only if sc_rbusy is false.
- * Must be called with sc_lock held.
+ * Must be called with sc_lock && sc_exlock held.
  * Must not be called from the interrupt context.
  */
 static void
@@ -5298,6 +5299,7 @@ audio_rmixer_start(struct audio_softc *s
 {
 
 	KASSERT(mutex_owned(sc->sc_lock));
+	KASSERT(sc->sc_exlock);
 	KASSERT(sc->sc_rbusy == false);
 
 	mutex_enter(sc->sc_intr_lock);



CVS commit: src/sys/dev/audio

2020-02-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 07:59:47 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Move #if DIAGNOSTIC..#endif to correct place.
It should ignore stray interrupts regardless of DIAGNOSTIC.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.48 src/sys/dev/audio/audio.c:1.49
--- src/sys/dev/audio/audio.c:1.48	Sat Feb 22 07:09:18 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 07:59:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.48 2020/02/22 07:09:18 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.49 2020/02/22 07:59:47 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.48 2020/02/22 07:09:18 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.49 2020/02/22 07:59:47 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -5224,12 +5224,12 @@ audio_pintr(void *arg)
 
 	if (sc->sc_dying)
 		return;
-#if defined(DIAGNOSTIC)
 	if (sc->sc_pbusy == false) {
+#if defined(DIAGNOSTIC)
 		device_printf(sc->sc_dev, "stray interrupt\n");
+#endif
 		return;
 	}
-#endif
 
 	mixer = sc->sc_pmixer;
 	mixer->hw_complete_counter += mixer->frames_per_block;
@@ -5492,12 +5492,12 @@ audio_rintr(void *arg)
 
 	if (sc->sc_dying)
 		return;
-#if defined(DIAGNOSTIC)
 	if (sc->sc_rbusy == false) {
+#if defined(DIAGNOSTIC)
 		device_printf(sc->sc_dev, "stray interrupt\n");
+#endif
 		return;
 	}
-#endif
 
 	mixer = sc->sc_rmixer;
 	mixer->hw_complete_counter += mixer->frames_per_block;



CVS commit: src/sys/dev/audio

2020-02-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 07:09:18 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
hw_if->query_format is already mandatory method.  Drop null checks.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.47 src/sys/dev/audio/audio.c:1.48
--- src/sys/dev/audio/audio.c:1.47	Sat Feb 22 06:58:39 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 07:09:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.47 2020/02/22 06:58:39 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.48 2020/02/22 07:09:18 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.47 2020/02/22 06:58:39 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.48 2020/02/22 07:09:18 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2690,15 +2690,11 @@ audio_ioctl(dev_t dev, struct audio_soft
 
 	case AUDIO_QUERYFORMAT:
 		query = (audio_format_query_t *)addr;
-		if (sc->hw_if->query_format) {
-			mutex_enter(sc->sc_lock);
-			error = sc->hw_if->query_format(sc->hw_hdl, query);
-			mutex_exit(sc->sc_lock);
-			/* Hide internal infomations */
-			query->fmt.driver_data = NULL;
-		} else {
-			error = ENODEV;
-		}
+		mutex_enter(sc->sc_lock);
+		error = sc->hw_if->query_format(sc->hw_hdl, query);
+		mutex_exit(sc->sc_lock);
+		/* Hide internal infomations */
+		query->fmt.driver_data = NULL;
 		break;
 
 	case AUDIO_GETFORMAT:
@@ -6226,21 +6222,6 @@ audio_hw_validate_format(struct audio_so
 
 	KASSERT(mutex_owned(sc->sc_lock));
 
-	/*
-	 * If query_format is not supported by hardware driver,
-	 * a rough check instead will be performed.
-	 * XXX This will gone in the future.
-	 */
-	if (sc->hw_if->query_format == NULL) {
-		if (fmt->encoding != AUDIO_ENCODING_SLINEAR_NE)
-			return EINVAL;
-		if (fmt->precision != AUDIO_INTERNAL_BITS)
-			return EINVAL;
-		if (fmt->stride != AUDIO_INTERNAL_BITS)
-			return EINVAL;
-		return 0;
-	}
-
 	for (index = 0; ; index++) {
 		query.index = index;
 		error = sc->hw_if->query_format(sc->hw_hdl, &query);



CVS commit: src/sys/dev/audio

2020-02-21 Thread Tetsuya Isaki
%d) is out of range (capacity:%d)",
-	func, ring->used, ring->capacity);
+	"called from %s: ring->used=%d ring->capacity=%d",
+	where, ring->used, ring->capacity);
 	if (ring->capacity == 0) {
 		KASSERTMSG(ring->mem == NULL,
-		"%s: capacity == 0 but mem != NULL", func);
+		"called from %s: capacity == 0 but mem != NULL", where);
 	} else {
 		KASSERTMSG(ring->mem != NULL,
-		"%s: capacity != 0 but mem == NULL", func);
+		"called from %s: capacity != 0 but mem == NULL", where);
 		KASSERTMSG(0 <= ring->head && ring->head < ring->capacity,
-		"%s: head(%d) is out of range (capacity:%d)",
-		func, ring->head, ring->capacity);
+		"called from %s: ring->head=%d ring->capacity=%d",
+		where, ring->head, ring->capacity);
 	}
 }
 #endif /* DIAGNOSTIC */

Index: src/sys/dev/audio/audiodef.h
diff -u src/sys/dev/audio/audiodef.h:1.8 src/sys/dev/audio/audiodef.h:1.9
--- src/sys/dev/audio/audiodef.h:1.8	Sat Jan 25 12:15:35 2020
+++ src/sys/dev/audio/audiodef.h	Sat Feb 22 06:58:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiodef.h,v 1.8 2020/01/25 12:15:35 jmcneill Exp $	*/
+/*	$NetBSD: audiodef.h,v 1.9 2020/02/22 06:58:39 isaki Exp $	*/
 
 /*
  * Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -296,8 +296,9 @@ static __inline int
 auring_round(const audio_ring_t *ring, int idx)
 {
 	DIAGNOSTIC_ring(ring);
-	KASSERT(idx >= 0);
-	KASSERT(idx < ring->capacity * 2);
+	KASSERTMSG(idx >= 0, "idx=%d", idx);
+	KASSERTMSG(idx < ring->capacity * 2,
+	"idx=%d ring->capacity=%d", idx, ring->capacity);
 
 	if (idx < ring->capacity) {
 		return idx;
@@ -324,7 +325,9 @@ auring_tail(const audio_ring_t *ring)
 static __inline aint_t *
 auring_headptr_aint(const audio_ring_t *ring)
 {
-	KASSERT(ring->fmt.stride == sizeof(aint_t) * NBBY);
+	KASSERTMSG(ring->fmt.stride == sizeof(aint_t) * NBBY,
+	"ring->fmt.stride=%d sizeof(aint_t)*NBBY=%zd",
+	ring->fmt.stride, sizeof(aint_t) * NBBY);
 
 	return (aint_t *)ring->mem + ring->head * ring->fmt.channels;
 }
@@ -337,7 +340,9 @@ auring_headptr_aint(const audio_ring_t *
 static __inline aint_t *
 auring_tailptr_aint(const audio_ring_t *ring)
 {
-	KASSERT(ring->fmt.stride == sizeof(aint_t) * NBBY);
+	KASSERTMSG(ring->fmt.stride == sizeof(aint_t) * NBBY,
+	"ring->fmt.stride=%d sizeof(aint_t)*NBBY=%zd",
+	ring->fmt.stride, sizeof(aint_t) * NBBY);
 
 	return (aint_t *)ring->mem + auring_tail(ring) * ring->fmt.channels;
 }



CVS commit: src/sys/dev/audio

2020-02-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 06:36:07 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Change two aprint_error_dev() to device_printf() (and improve messages).
This is also called from other than boot.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.45 src/sys/dev/audio/audio.c:1.46
--- src/sys/dev/audio/audio.c:1.45	Sat Feb 22 06:28:10 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 06:36:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.45 2020/02/22 06:28:10 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.46 2020/02/22 06:36:07 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.45 2020/02/22 06:28:10 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.46 2020/02/22 06:36:07 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -5944,8 +5944,9 @@ audio_mixers_init(struct audio_softc *sc
 		}
 		error = audio_mixer_init(sc, AUMODE_PLAY, phwfmt, pfil);
 		if (error) {
-			aprint_error_dev(sc->sc_dev,
-			"configuring playback mode failed\n");
+			device_printf(sc->sc_dev,
+			"configuring playback mode failed with %d\n",
+			error);
 			kmem_free(sc->sc_pmixer, sizeof(*sc->sc_pmixer));
 			sc->sc_pmixer = NULL;
 			return error;
@@ -5962,8 +5963,9 @@ audio_mixers_init(struct audio_softc *sc
 		}
 		error = audio_mixer_init(sc, AUMODE_RECORD, rhwfmt, rfil);
 		if (error) {
-			aprint_error_dev(sc->sc_dev,
-			"configuring record mode failed\n");
+			device_printf(sc->sc_dev,
+			"configuring record mode failed with %d\n",
+			error);
 			kmem_free(sc->sc_rmixer, sizeof(*sc->sc_rmixer));
 			sc->sc_rmixer = NULL;
 			return error;



CVS commit: src/sys/dev/audio

2020-02-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 06:28:10 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
const-ify.  These arguments are no longer written back.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.44 src/sys/dev/audio/audio.c:1.45
--- src/sys/dev/audio/audio.c:1.44	Sat Feb 22 06:22:46 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 06:28:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.44 2020/02/22 06:22:46 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.45 2020/02/22 06:28:10 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.44 2020/02/22 06:22:46 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.45 2020/02/22 06:28:10 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -547,7 +547,7 @@ static void audio_track_setinfo_water(au
 static int audio_hw_setinfo(struct audio_softc *, const struct audio_info *,
 	struct audio_info *);
 static int audio_hw_set_format(struct audio_softc *, int,
-	audio_format2_t *, audio_format2_t *,
+	const audio_format2_t *, const audio_format2_t *,
 	audio_filter_reg_t *, audio_filter_reg_t *);
 static int audiogetinfo(struct audio_softc *, struct audio_info *, int,
 	audio_file_t *);
@@ -6993,7 +6993,6 @@ abort:
  *   parameters.
  * - pfil and rfil must be zero-filled.
  * If successful,
- * - phwfmt, rhwfmt will be overwritten by hardware format.
  * - pfil, rfil will be filled with filter information specified by the
  *   hardware driver.
  * and then returns 0.  Otherwise returns errno.
@@ -7001,7 +7000,7 @@ abort:
  */
 static int
 audio_hw_set_format(struct audio_softc *sc, int setmode,
-	audio_format2_t *phwfmt, audio_format2_t *rhwfmt,
+	const audio_format2_t *phwfmt, const audio_format2_t *rhwfmt,
 	audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
 	audio_params_t pp, rp;



CVS commit: src/sys/dev/audio

2020-02-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 06:22:46 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Fix/Update comments.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.43 src/sys/dev/audio/audio.c:1.44
--- src/sys/dev/audio/audio.c:1.43	Sat Feb 22 05:51:39 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 06:22:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.43 2020/02/22 05:51:39 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.44 2020/02/22 06:22:46 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.43 2020/02/22 05:51:39 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.44 2020/02/22 06:22:46 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -6274,9 +6274,9 @@ audio_hw_validate_format(struct audio_so
 /*
  * Set track mixer's format depending on ai->mode.
  * If AUMODE_PLAY is set in ai->mode, it set up the playback mixer
- * with ai.play.{channels, sample_rate}.
+ * with ai.play.*.
  * If AUMODE_RECORD is set in ai->mode, it set up the recording mixer
- * with ai.record.{channels, sample_rate}.
+ * with ai.record.*.
  * All other fields in ai are ignored.
  * If successful returns 0.  Otherwise returns errno.
  * This function does not roll back even if it fails.
@@ -6304,7 +6304,6 @@ audio_mixers_set_format(struct audio_sof
 	if (!SPECIFIED(ai->mode) || ai->mode == 0)
 		return ENOTTY;
 
-	/* Only channels and sample_rate are changeable. */
 	mode = ai->mode;
 	if ((mode & AUMODE_PLAY)) {
 		phwfmt.encoding= ai->play.encoding;
@@ -6844,7 +6843,7 @@ audio_track_setinfo_water(audio_track_t 
 }
 
 /*
- * Set hardware part of *ai.
+ * Set hardware part of *newai.
  * The parameters handled here are *.port, *.gain, *.balance and monitor_gain.
  * If oldai is specified, previous parameters are stored.
  * This function itself does not roll back if error occurred.



CVS commit: src/tests/dev/audio

2020-02-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 05:53:19 UTC 2020

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
Update AUDIO_SETINFO_channels test.
The kernel limits the number of channels that userland apps can set to
the number of channels supported by the hardware or less.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/dev/audio/audiotest.c

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

Modified files:

Index: src/tests/dev/audio/audiotest.c
diff -u src/tests/dev/audio/audiotest.c:1.5 src/tests/dev/audio/audiotest.c:1.6
--- src/tests/dev/audio/audiotest.c:1.5	Tue Feb 18 12:11:26 2020
+++ src/tests/dev/audio/audiotest.c	Sat Feb 22 05:53:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiotest.c,v 1.5 2020/02/18 12:11:26 isaki Exp $	*/
+/*	$NetBSD: audiotest.c,v 1.6 2020/02/22 05:53:19 isaki Exp $	*/
 
 /*
  * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: audiotest.c,v 1.5 2020/02/18 12:11:26 isaki Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.6 2020/02/22 05:53:19 isaki Exp $");
 
 #include 
 #include 
@@ -5413,11 +5413,13 @@ DEF(AUDIO_SETINFO_params_simul)
  */
 DEF(AUDIO_SETINFO_channels)
 {
+	struct audio_info hwinfo;
 	struct audio_info ai;
 	int mode;
 	int r;
 	int fd;
 	int i;
+	unsigned int ch;
 	struct {
 		int ch;
 		bool expected;
@@ -5425,9 +5427,6 @@ DEF(AUDIO_SETINFO_channels)
 		{  0,	false },
 		{  1,	true },	/* monaural */
 		{  2,	true },	/* stereo */
-		{  3,	true },	/* multi channels */
-		{ 12,	true },	/* upper limit */
-		{ 13,	false },
 	};
 
 	TEST("AUDIO_SETINFO_channels");
@@ -5444,8 +5443,12 @@ DEF(AUDIO_SETINFO_channels)
 	fd = OPEN(devaudio, mode);
 	REQUIRED_SYS_OK(fd);
 
+	/*
+	 * The audio layer always supports monaural and stereo regardless of
+	 * the hardware capability.
+	 */
 	for (i = 0; i < (int)__arraycount(table); i++) {
-		int ch = table[i].ch;
+		ch = table[i].ch;
 		bool expected = table[i].expected;
 
 		AUDIO_INITINFO(&ai);
@@ -5470,6 +5473,52 @@ DEF(AUDIO_SETINFO_channels)
 		}
 	}
 
+	/*
+	 * The maximum number of supported channels depends the hardware.
+	 */
+	/* Get the number of channels that the hardware supports */
+	r = IOCTL(fd, AUDIO_GETFORMAT, &hwinfo, "");
+	REQUIRED_SYS_EQ(0, r);
+
+	if ((hwinfo.mode & AUMODE_PLAY)) {
+		DPRINTF("  > hwinfo.play.channels = %d\n",
+		hwinfo.play.channels);
+		for (ch = 3; ch <= hwinfo.play.channels; ch++) {
+			AUDIO_INITINFO(&ai);
+			ai.play.channels = ch;
+			r = IOCTL(fd, AUDIO_SETINFO, &ai, "channels=%d", ch);
+			XP_SYS_EQ(0, r);
+
+			r = IOCTL(fd, AUDIO_GETBUFINFO, &ai, "");
+			XP_SYS_EQ(0, r);
+			XP_EQ(ch, ai.play.channels);
+		}
+
+		AUDIO_INITINFO(&ai);
+		ai.play.channels = ch;
+		r = IOCTL(fd, AUDIO_SETINFO, &ai, "channels=%d", ch);
+		XP_SYS_NG(EINVAL, r);
+	}
+	if ((hwinfo.mode & AUMODE_RECORD)) {
+		DPRINTF("  > hwinfo.record.channels = %d\n",
+		hwinfo.record.channels);
+		for (ch = 3; ch <= hwinfo.record.channels; ch++) {
+			AUDIO_INITINFO(&ai);
+			ai.record.channels = ch;
+			r = IOCTL(fd, AUDIO_SETINFO, &ai, "channels=%d", ch);
+			XP_SYS_EQ(0, r);
+
+			r = IOCTL(fd, AUDIO_GETBUFINFO, &ai, "");
+			XP_SYS_EQ(0, r);
+			XP_EQ(ch, ai.record.channels);
+		}
+
+		AUDIO_INITINFO(&ai);
+		ai.record.channels = ch;
+		r = IOCTL(fd, AUDIO_SETINFO, &ai, "channels=%d", ch);
+		XP_SYS_NG(EINVAL, r);
+	}
+
 	r = CLOSE(fd);
 	XP_SYS_EQ(0, r);
 }



CVS commit: src/sys/dev/audio

2020-02-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 22 05:51:39 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Limit the number of channels that userland apps can set (by AUDIO_SETINFO)
to the number of channels supported by the hardware or less, if the hardware
supports multi channels.
- On monaural or stereo hardware, userland apps can always set 1ch or 2ch.
  The kernel (audio layer) can convert mono-stereo each other.
- On 3ch (2.1ch) hardware, for example, userland apps can set 1, 2, or 3ch,
  but not 4ch or more.
This allows userland apps to know actual number of channels supported by
the hardware in the same way as before.
PR kern/54973.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.42 src/sys/dev/audio/audio.c:1.43
--- src/sys/dev/audio/audio.c:1.42	Sat Feb 15 02:47:00 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 22 05:51:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.42 2020/02/15 02:47:00 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.43 2020/02/22 05:51:39 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.42 2020/02/15 02:47:00 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.43 2020/02/22 05:51:39 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -541,7 +541,7 @@ static __inline int audio_track_readable
 static int audio_file_setinfo(struct audio_softc *, audio_file_t *,
 	const struct audio_info *);
 static int audio_track_setinfo_check(audio_format2_t *,
-	const struct audio_prinfo *);
+	const struct audio_prinfo *, const audio_format2_t *);
 static void audio_track_setinfo_water(audio_track_t *,
 	const struct audio_info *);
 static int audio_hw_setinfo(struct audio_softc *, const struct audio_info *,
@@ -6634,7 +6634,8 @@ audio_file_setinfo(struct audio_softc *s
 	}
 
 	if (ptrack) {
-		pchanges = audio_track_setinfo_check(&pfmt, pi);
+		pchanges = audio_track_setinfo_check(&pfmt, pi,
+		&sc->sc_pmixer->hwbuf.fmt);
 		if (pchanges == -1) {
 #if defined(AUDIO_DEBUG)
 			char fmtbuf[64];
@@ -6648,7 +6649,8 @@ audio_file_setinfo(struct audio_softc *s
 			pchanges = 1;
 	}
 	if (rtrack) {
-		rchanges = audio_track_setinfo_check(&rfmt, ri);
+		rchanges = audio_track_setinfo_check(&rfmt, ri,
+		&sc->sc_rmixer->hwbuf.fmt);
 		if (rchanges == -1) {
 #if defined(AUDIO_DEBUG)
 			char fmtbuf[64];
@@ -6760,7 +6762,8 @@ abort1:
  * Return value of -1 indicates that error EINVAL has occurred.
  */
 static int
-audio_track_setinfo_check(audio_format2_t *fmt, const struct audio_prinfo *info)
+audio_track_setinfo_check(audio_format2_t *fmt, const struct audio_prinfo *info,
+	const audio_format2_t *hwfmt)
 {
 	int changes;
 
@@ -6784,6 +6787,13 @@ audio_track_setinfo_check(audio_format2_
 		changes = 1;
 	}
 	if (SPECIFIED(info->channels)) {
+		/*
+		 * We can convert between monaural and stereo each other.
+		 * We can reduce than the number of channels that the hardware
+		 * supports.
+		 */
+		if (info->channels > 2 && info->channels > hwfmt->channels)
+			return -1;
 		fmt->channels = info->channels;
 		changes = 1;
 	}



CVS commit: src/tests/dev/audio

2020-02-18 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Feb 18 12:11:27 UTC 2020

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
Add tests.
 AUDIO_SETINFO_channels
 AUDIO_SETINFO_sample_rate
 AUDIO_SETINFO_sample_rate_0


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/dev/audio/audiotest.c

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

Modified files:

Index: src/tests/dev/audio/audiotest.c
diff -u src/tests/dev/audio/audiotest.c:1.4 src/tests/dev/audio/audiotest.c:1.5
--- src/tests/dev/audio/audiotest.c:1.4	Fri Feb 14 13:20:48 2020
+++ src/tests/dev/audio/audiotest.c	Tue Feb 18 12:11:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiotest.c,v 1.4 2020/02/14 13:20:48 isaki Exp $	*/
+/*	$NetBSD: audiotest.c,v 1.5 2020/02/18 12:11:26 isaki Exp $	*/
 
 /*
  * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: audiotest.c,v 1.4 2020/02/14 13:20:48 isaki Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.5 2020/02/18 12:11:26 isaki Exp $");
 
 #include 
 #include 
@@ -5405,6 +5405,176 @@ DEF(AUDIO_SETINFO_params_simul)
 }
 
 /*
+ * AUDIO_SETINFO(encoding/precision) is tested in AUDIO_GETENC_range below.
+ */
+
+/*
+ * Check whether the number of channels can be set.
+ */
+DEF(AUDIO_SETINFO_channels)
+{
+	struct audio_info ai;
+	int mode;
+	int r;
+	int fd;
+	int i;
+	struct {
+		int ch;
+		bool expected;
+	} table[] = {
+		{  0,	false },
+		{  1,	true },	/* monaural */
+		{  2,	true },	/* stereo */
+		{  3,	true },	/* multi channels */
+		{ 12,	true },	/* upper limit */
+		{ 13,	false },
+	};
+
+	TEST("AUDIO_SETINFO_channels");
+	if (netbsd < 8) {
+		/*
+		 * On NetBSD7, the result depends the hardware and there is
+		 * no way to know it.
+		 */
+		XP_SKIP("The test doesn't make sense on NetBSD7");
+		return;
+	}
+
+	mode = openable_mode();
+	fd = OPEN(devaudio, mode);
+	REQUIRED_SYS_OK(fd);
+
+	for (i = 0; i < (int)__arraycount(table); i++) {
+		int ch = table[i].ch;
+		bool expected = table[i].expected;
+
+		AUDIO_INITINFO(&ai);
+		if (mode != O_RDONLY)
+			ai.play.channels = ch;
+		if (mode != O_WRONLY)
+			ai.record.channels = ch;
+		r = IOCTL(fd, AUDIO_SETINFO, &ai, "channels=%d", ch);
+		if (expected) {
+			/* Expects to succeed */
+			XP_SYS_EQ(0, r);
+
+			r = IOCTL(fd, AUDIO_GETBUFINFO, &ai, "");
+			XP_SYS_EQ(0, r);
+			if (mode != O_RDONLY)
+XP_EQ(ch, ai.play.channels);
+			if (mode != O_WRONLY)
+XP_EQ(ch, ai.record.channels);
+		} else {
+			/* Expects to fail */
+			XP_SYS_NG(EINVAL, r);
+		}
+	}
+
+	r = CLOSE(fd);
+	XP_SYS_EQ(0, r);
+}
+
+/*
+ * Check whether the sample rate can be set.
+ */
+DEF(AUDIO_SETINFO_sample_rate)
+{
+	struct audio_info ai;
+	int mode;
+	int r;
+	int fd;
+	int i;
+	struct {
+		int freq;
+		bool expected;
+	} table[] = {
+		{999,	false },
+		{   1000,	true },	/* lower limit */
+		{  48000,	true },
+		{ 192000,	true },	/* upper limit */
+		{ 192001,	false },
+	};
+
+	TEST("AUDIO_SETINFO_sample_rate");
+	if (netbsd < 8) {
+		/*
+		 * On NetBSD7, the result depends the hardware and there is
+		 * no way to know it.
+		 */
+		XP_SKIP("The test doesn't make sense on NetBSD7");
+		return;
+	}
+
+	mode = openable_mode();
+	fd = OPEN(devaudio, mode);
+	REQUIRED_SYS_OK(fd);
+
+	for (i = 0; i < (int)__arraycount(table); i++) {
+		int freq = table[i].freq;
+		bool expected = table[i].expected;
+
+		AUDIO_INITINFO(&ai);
+		if (mode != O_RDONLY)
+			ai.play.sample_rate = freq;
+		if (mode != O_WRONLY)
+			ai.record.sample_rate = freq;
+		r = IOCTL(fd, AUDIO_SETINFO, &ai, "sample_rate=%d", freq);
+		if (expected) {
+			/* Expects to succeed */
+			XP_SYS_EQ(0, r);
+
+			r = IOCTL(fd, AUDIO_GETBUFINFO, &ai, "");
+			XP_SYS_EQ(0, r);
+			if (mode != O_RDONLY)
+XP_EQ(freq, ai.play.sample_rate);
+			if (mode != O_WRONLY)
+XP_EQ(freq, ai.record.sample_rate);
+		} else {
+			/* Expects to fail */
+			XP_SYS_NG(EINVAL, r);
+		}
+	}
+
+	r = CLOSE(fd);
+	XP_SYS_EQ(0, r);
+}
+
+/*
+ * SETINFO(sample_rate = 0) should fail correctly.
+ */
+DEF(AUDIO_SETINFO_sample_rate_0)
+{
+	struct audio_info ai;
+	int mode;
+	int r;
+	int fd;
+
+	TEST("AUDIO_SETINFO_sample_rate_0");
+	if (netbsd < 9) {
+		/*
+		 * On NetBSD7,8 this will block system call and you will not
+		 * even be able to shutdown...
+		 */
+		XP_SKIP("This will cause an infinate loop in the kernel");
+		return;
+	}
+
+	mode = openable_mode();
+	fd = OPEN(devaudio, mode);
+	REQUIRED_SYS_OK(fd);
+
+	AUDIO_INITINFO(&ai);
+	ai.play.sample_rate = 0;
+	ai.record.sample_rate = 0;
+	r = IOCTL(fd, AUDIO_SETINFO, &ai, "sample_rate=0");
+	/* Expects to fail */
+	XP_SYS_NG(EINVAL, r);
+
+	r = CLOSE(fd);
+	XP_SYS_EQ(0, r);
+}
+
+/*
  * Check whether the pause/unpause works.

CVS commit: src/sys/dev/hdaudio

2020-02-14 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 15 03:04:45 UTC 2020

Modified Files:
src/sys/dev/hdaudio: hdafg.c

Log Message:
Enumerating probably always starts from sc->sc_startnode.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/hdaudio/hdafg.c

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

Modified files:

Index: src/sys/dev/hdaudio/hdafg.c
diff -u src/sys/dev/hdaudio/hdafg.c:1.20 src/sys/dev/hdaudio/hdafg.c:1.21
--- src/sys/dev/hdaudio/hdafg.c:1.20	Thu Jan 30 00:21:23 2020
+++ src/sys/dev/hdaudio/hdafg.c	Sat Feb 15 03:04:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: hdafg.c,v 1.20 2020/01/30 00:21:23 jmcneill Exp $ */
+/* $NetBSD: hdafg.c,v 1.21 2020/02/15 03:04:45 isaki Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd 
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.20 2020/01/30 00:21:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.21 2020/02/15 03:04:45 isaki Exp $");
 
 #include 
 #include 
@@ -796,7 +796,7 @@ hdafg_assoc_count_channels(struct hdafg_
 		if (as->as_dacs[i])
 			dacmap[as->as_dacs[i]] = 1;
 
-	for (i = 1; i < sc->sc_endnode; i++) {
+	for (i = sc->sc_startnode; i < sc->sc_endnode; i++) {
 		if (!dacmap[i])
 			continue;
 		w = hdafg_widget_lookup(sc, i);



CVS commit: src/sys/dev/audio

2020-02-14 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 15 02:47:00 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Remove incorrect KASSERT(!mutex_owned()).
Pointed out by riastradh@.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.41 src/sys/dev/audio/audio.c:1.42
--- src/sys/dev/audio/audio.c:1.41	Sat Jan 11 04:53:10 2020
+++ src/sys/dev/audio/audio.c	Sat Feb 15 02:47:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.41 2020/01/11 04:53:10 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.42 2020/02/15 02:47:00 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.41 2020/01/11 04:53:10 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.42 2020/02/15 02:47:00 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1363,14 +1363,13 @@ audio_attach_mi(const struct audio_hw_if
 /*
  * Acquire sc_lock and enter exlock critical section.
  * If successful, it returns 0.  Otherwise returns errno.
+ * Must be called without sc_lock held.
  */
 static int
 audio_enter_exclusive(struct audio_softc *sc)
 {
 	int error;
 
-	KASSERT(!mutex_owned(sc->sc_lock));
-
 	mutex_enter(sc->sc_lock);
 	if (sc->sc_dying) {
 		mutex_exit(sc->sc_lock);
@@ -2096,7 +2095,7 @@ bad1:
 }
 
 /*
- * Must NOT called with sc_lock nor sc_exlock held.
+ * Must be called without sc_lock nor sc_exlock held.
  */
 int
 audio_close(struct audio_softc *sc, audio_file_t *file)
@@ -2104,8 +2103,6 @@ audio_close(struct audio_softc *sc, audi
 	audio_track_t *oldtrack;
 	int error;
 
-	KASSERT(!mutex_owned(sc->sc_lock));
-
 	TRACEF(1, file, "%spid=%d.%d po=%d ro=%d",
 	(audiodebug >= 3) ? "start " : "",
 	(int)curproc->p_pid, (int)curlwp->l_lid,
@@ -2206,6 +2203,9 @@ audio_close(struct audio_softc *sc, audi
 	return 0;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_read(struct audio_softc *sc, struct uio *uio, int ioflag,
 	audio_file_t *file)
@@ -2215,8 +2215,6 @@ audio_read(struct audio_softc *sc, struc
 	audio_ring_t *input;
 	int error;
 
-	KASSERT(!mutex_owned(sc->sc_lock));
-
 	/*
 	 * On half-duplex hardware, O_RDWR is treated as O_WRONLY.
 	 * However read() system call itself can be called because it's
@@ -2333,6 +2331,9 @@ audio_file_clear(struct audio_softc *sc,
 		audio_track_clear(sc, file->rtrack);
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_write(struct audio_softc *sc, struct uio *uio, int ioflag,
 	audio_file_t *file)
@@ -2342,8 +2343,6 @@ audio_write(struct audio_softc *sc, stru
 	audio_ring_t *outbuf;
 	int error;
 
-	KASSERT(!mutex_owned(sc->sc_lock));
-
 	track = file->ptrack;
 	KASSERT(track);
 
@@ -2455,6 +2454,9 @@ abort:
 	return error;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_ioctl(dev_t dev, struct audio_softc *sc, u_long cmd, void *addr, int flag,
 	struct lwp *l, audio_file_t *file)
@@ -2470,8 +2472,6 @@ audio_ioctl(dev_t dev, struct audio_soft
 	int index;
 	int error;
 
-	KASSERT(!mutex_owned(sc->sc_lock));
-
 #if defined(AUDIO_DEBUG)
 	const char *ioctlnames[] = {
 		" AUDIO_GETINFO",	/* 21 */
@@ -2763,6 +2763,9 @@ audio_track_readablebytes(const audio_tr
 	return bytes;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_poll(struct audio_softc *sc, int events, struct lwp *l,
 	audio_file_t *file)
@@ -2772,8 +2775,6 @@ audio_poll(struct audio_softc *sc, int e
 	bool in_is_valid;
 	bool out_is_valid;
 
-	KASSERT(!mutex_owned(sc->sc_lock));
-
 #if defined(AUDIO_DEBUG)
 #define POLLEV_BITMAP "\177\020" \
 	"b\10WRBAND\0" \
@@ -2921,13 +2922,14 @@ filt_audiowrite_event(struct knote *kn, 
 	return (track->usrbuf.used < track->usrbuf_usedlow);
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_kqfilter(struct audio_softc *sc, audio_file_t *file, struct knote *kn)
 {
 	struct klist *klist;
 
-	KASSERT(!mutex_owned(sc->sc_lock));
-
 	TRACEF(3, file, "kn=%p kn_filter=%x", kn, (int)kn->kn_filter);
 
 	switch (kn->kn_filter) {
@@ -2954,6 +2956,9 @@ audio_kqfilter(struct audio_softc *sc, a
 	return 0;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_mmap(struct audio_softc *sc, off_t *offp, size_t len, int prot,
 	int *flagsp, int *advicep, struct uvm_object **uobjp, int *maxprotp,
@@ -2963,8 +2968,6 @@ audio_mmap(struct audio_softc *sc, off_t
 	vsize_t vsize;
 	int error;
 
-	KASSERT(!mutex_owned(sc->sc_lock));
-
 	TRACEF(2, file, "off=%lld, prot=%d", (long long)(*offp), prot);
 
 	if (*offp < 0)
@@ -7709,6 +7712,9 @@ mixer_close(struct audio_softc *sc, audi
 	return 0;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 mixer_i

CVS commit: src/tests/dev/audio

2020-02-14 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri Feb 14 13:20:48 UTC 2020

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
Improve around {audioctl_,}open_multiuser.
- Make multiuser bool and remove newval.
- try_audioctl_open_multiuser() doesn't need multiuser argument.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/dev/audio/audiotest.c

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

Modified files:

Index: src/tests/dev/audio/audiotest.c
diff -u src/tests/dev/audio/audiotest.c:1.3 src/tests/dev/audio/audiotest.c:1.4
--- src/tests/dev/audio/audiotest.c:1.3	Thu Feb 13 18:06:26 2020
+++ src/tests/dev/audio/audiotest.c	Fri Feb 14 13:20:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiotest.c,v 1.3 2020/02/13 18:06:26 tnn Exp $	*/
+/*	$NetBSD: audiotest.c,v 1.4 2020/02/14 13:20:48 isaki Exp $	*/
 
 /*
  * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: audiotest.c,v 1.3 2020/02/13 18:06:26 tnn Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.4 2020/02/14 13:20:48 isaki Exp $");
 
 #include 
 #include 
@@ -1381,8 +1381,8 @@ void test_open_audio(int);
 void test_open_sound(int);
 void test_open_audioctl(int);
 void test_open_simul(int, int);
-void try_open_multiuser(int);
-void test_open_multiuser(int);
+void try_open_multiuser(bool);
+void test_open_multiuser(bool);
 void test_rdwr_fallback(int, bool, bool);
 void test_rdwr_two(int, int);
 void test_mmap_mode(int, int);
@@ -1400,8 +1400,8 @@ void getenc_check_encodings(int, int[][5
 void test_AUDIO_ERROR(int);
 void test_audioctl_open_1(int, int);
 void test_audioctl_open_2(int, int);
-void try_audioctl_open_multiuser(int, const char *, const char *);
-void test_audioctl_open_multiuser(int, const char *, const char *);
+void try_audioctl_open_multiuser(const char *, const char *);
+void test_audioctl_open_multiuser(bool, const char *, const char *);
 void test_audioctl_rw(int);
 
 #define DEF(name) \
@@ -2219,7 +2219,7 @@ DEF(open_simul_RDWR_RDWR)	{ test_open_si
  * /dev/audio can be opened by other user who opens /dev/audio.
  */
 void
-try_open_multiuser(int multiuser)
+try_open_multiuser(bool multiuser)
 {
 	int fd0;
 	int fd1;
@@ -2295,10 +2295,9 @@ try_open_multiuser(int multiuser)
  * XXX XP_* macros are not compatible with on-error-goto, we need try-catch...
  */
 void
-test_open_multiuser(int multiuser)
+test_open_multiuser(bool multiuser)
 {
 	char mibname[32];
-	bool newval;
 	bool oldval;
 	size_t oldlen;
 	int r;
@@ -2327,26 +2326,24 @@ test_open_multiuser(int multiuser)
 
 	/* Change if necessary */
 	if (oldval != multiuser) {
-		newval = multiuser;
-		r = SYSCTLBYNAME(mibname, NULL, NULL, &newval, sizeof(newval));
+		r = SYSCTLBYNAME(mibname, NULL, NULL, &multiuser,
+		sizeof(multiuser));
 		REQUIRED_SYS_EQ(0, r);
 		DPRINTF("  > new multiuser=%d\n", multiuser);
-	} else {
-		newval = oldval;
 	}
 
 	/* Do test */
 	try_open_multiuser(multiuser);
 
 	/* Restore multiuser mode */
-	if (oldval != newval) {
+	if (oldval != multiuser) {
 		DPRINTF("  > restore multiuser to %d\n", oldval);
 		r = SYSCTLBYNAME(mibname, NULL, NULL, &oldval, sizeof(oldval));
 		REQUIRED_SYS_EQ(0, r);
 	}
 }
-DEF(open_multiuser_0)	{ test_open_multiuser(0); }
-DEF(open_multiuser_1)	{ test_open_multiuser(1); }
+DEF(open_multiuser_0)	{ test_open_multiuser(false); }
+DEF(open_multiuser_1)	{ test_open_multiuser(true); }
 
 /*
  * Normal playback (with PLAY_ALL).
@@ -6034,12 +6031,13 @@ DEF(audioctl_open_simul)
 }
 
 /*
- * /dev/audioctl can be opened by other user who opens /dev/audioctl.
- * /dev/audioctl can be opened by other user who opens /dev/audio.
- * /dev/audiocan be opened by other user who opens /dev/audioct.
+ * /dev/audioctl can be opened by other user who opens /dev/audioctl,
+ * /dev/audioctl can be opened by other user who opens /dev/audio,
+ * /dev/audiocan be opened by other user who opens /dev/audioctl,
+ * regardless of multiuser mode.
  */
 void
-try_audioctl_open_multiuser(int multiuser, const char *dev1, const char *dev2)
+try_audioctl_open_multiuser(const char *dev1, const char *dev2)
 {
 	int fd1;
 	int fd2;
@@ -6076,10 +6074,10 @@ try_audioctl_open_multiuser(int multiuse
  * XXX XP_* macros are not compatible with on-error-goto, we need try-catch...
  */
 void
-test_audioctl_open_multiuser(int multiuser, const char *dev1, const char *dev2)
+test_audioctl_open_multiuser(bool multiuser,
+	const char *dev1, const char *dev2)
 {
 	char mibname[32];
-	bool newval;
 	bool oldval;
 	size_t oldlen;
 	int r;
@@ -6107,19 +6105,17 @@ test_audioctl_open_multiuser(int multius
 
 	/* Change if necessary */
 	if (oldval != multiuser) {
-		newval = multiuser;
-		r = SYSCTLBYNAME(mibname, NULL, NULL, &newval, sizeof(newval));
+		r = SYSCTLBYNAME(mibname, NULL, NULL, &multiuser,
+		sizeof(multiuser));
 

CVS commit: src/sys/arch/x68k/stand/mboot

2020-02-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb  1 08:08:15 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/mboot: Makefile

Log Message:
Make it output 68000 binary.
CFLAGS already has -m68000 but AFLAGS didn't.

This change makes it proceed to next stage1 even if MPU is 68000.
All stage1 bootloader displays an error message if MPU is 68000.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x68k/stand/mboot/Makefile

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/x68k/stand/mboot/Makefile
diff -u src/sys/arch/x68k/stand/mboot/Makefile:1.17 src/sys/arch/x68k/stand/mboot/Makefile:1.18
--- src/sys/arch/x68k/stand/mboot/Makefile:1.17	Fri Aug  8 15:19:51 2014
+++ src/sys/arch/x68k/stand/mboot/Makefile	Sat Feb  1 08:08:15 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.17 2014/08/08 15:19:51 isaki Exp $
+#	$NetBSD: Makefile,v 1.18 2020/02/01 08:08:15 isaki Exp $
 
 NOMAN=		# defined
 .include 
@@ -24,6 +24,7 @@ CPPFLAGS+=	-I${.CURDIR}/../libiocs
 CPPFLAGS+=	-DTEXTADDR="0x${TEXT}" 
 CPPFLAGS+=	-DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\"
 CFLAGS=		-Wno-main -Os -m68000
+AFLAGS+=	-m68000
 
 LINKFLAGS=	-N -static -Ttext ${TEXT}
 LIBIOCS!=	cd ${.CURDIR}/../libiocs && ${PRINTOBJDIR}



CVS commit: src/sys/arch/x68k/stand/xxboot

2020-01-28 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Jan 28 12:02:02 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot boot.S

Log Message:
Set heap area explicitly.
Until the load address was moved, the heap was placed at _end (it's default)
and it was large space.  After moving, this default space was too small.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot \
src/sys/arch/x68k/stand/xxboot/boot.S

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/x68k/stand/xxboot/Makefile.xxboot
diff -u src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.11 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.12
--- src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.11	Sat Jan 18 07:25:12 2020
+++ src/sys/arch/x68k/stand/xxboot/Makefile.xxboot	Tue Jan 28 12:02:02 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.xxboot,v 1.11 2020/01/18 07:25:12 isaki Exp $
+#	$NetBSD: Makefile.xxboot,v 1.12 2020/01/28 12:02:02 isaki Exp $
 
 NOMAN=		# defined
 
@@ -36,6 +36,7 @@ CPPFLAGS+= -DTEXTADDR="$(TEXT)" -DBOOT_T
 CPPFLAGS+= -DTDSIZE="$(TEXTDATASIZE)"
 CPPFLAGS+= -DPROG=\"$(PROG)\" -DBOOT_VERS=\"$(VERSION)\"
 CPPFLAGS+= -DBOOT_STAGE1 $(BOOTCPPFLAGS)
+CPPFLAGS+= -DHEAP_START=0x0010
 CPPFLAGS+= -nostdinc -I${.OBJDIR} -I${S}
 CPPFLAGS+= -I$M/stand/libiocs -I$M/stand/libsa -I$M/stand/common
 AFLAGS=	   ${CFLAGS:M-[ID]*}
Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u src/sys/arch/x68k/stand/xxboot/boot.S:1.11 src/sys/arch/x68k/stand/xxboot/boot.S:1.12
--- src/sys/arch/x68k/stand/xxboot/boot.S:1.11	Tue Jan 28 11:57:22 2020
+++ src/sys/arch/x68k/stand/xxboot/boot.S	Tue Jan 28 12:02:02 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.11 2020/01/28 11:57:22 isaki Exp $
+| $NetBSD: boot.S,v 1.12 2020/01/28 12:02:02 isaki Exp $
 
 |
 | (1) IPL (or previous stage loader) loads first 1KB of this primary
@@ -37,6 +37,7 @@
 |  ~~~~~~
 |  ::::<-SP::<-SP
 |  + - - - - - -++ - - - - - -++ - - - - - -+0x10
+|  :::(heap)  ::(heap)  :
 |  ::::::
 |
 



CVS commit: src/sys/arch/x68k/stand

2020-01-28 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Jan 28 11:57:22 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S boot_ufs.ldscript
src/sys/arch/x68k/stand/xxboot: boot.S xxboot.ldscript

Log Message:
Revert placing .bss right after .data, and make .bss fixed at 0x5000.
.bss placed right after .data was overwritten when first 1KB loads full
.text+.data.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x68k/stand/xxboot/boot.S
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript

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/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.18 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.19
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.18	Tue Jan 28 11:52:21 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Tue Jan 28 11:57:22 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.18 2020/01/28 11:52:21 isaki Exp $
+| $NetBSD: boot.S,v 1.19 2020/01/28 11:57:22 isaki Exp $
 
 |
 | (1) IPL (or previous stage loader) loads first 1KB of this primary
@@ -27,9 +27,10 @@
 |  ::++++0x003000
 |  ::|full primary||full primary|
 |  ::|boot loader ||boot loader |
-|  ::++++
-|  ::::::
-|  ::::++0x006000
+|  ::|(text+data) ||(text+data) |
+|  ::++++0x005000
+|  ::|(bss)   ||(bss)   |
+|  ::++++0x006000
 |  ::::| /boot  |
 |  ::::++
 |  ::::::

Index: src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
diff -u src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.7 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.8
--- src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.7	Sat Jan 18 07:25:11 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript	Tue Jan 28 11:57:22 2020
@@ -35,6 +35,7 @@ SECTIONS
 edata  =  .;
 _edata  =  .;
   }
+  . = TEXTADDR + 0x2000;
   .bss :
   {
 __bss_start = .;

Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u src/sys/arch/x68k/stand/xxboot/boot.S:1.10 src/sys/arch/x68k/stand/xxboot/boot.S:1.11
--- src/sys/arch/x68k/stand/xxboot/boot.S:1.10	Tue Jan 28 11:52:21 2020
+++ src/sys/arch/x68k/stand/xxboot/boot.S	Tue Jan 28 11:57:22 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.10 2020/01/28 11:52:21 isaki Exp $
+| $NetBSD: boot.S,v 1.11 2020/01/28 11:57:22 isaki Exp $
 
 |
 | (1) IPL (or previous stage loader) loads first 1KB of this primary
@@ -27,9 +27,10 @@
 |  ::++++0x003000
 |  ::|full primary||full primary|
 |  ::|boot loader ||boot loader |
-|  ::++++
-|  ::::::
-|  ::::++0x006000
+|  ::|(text+data) ||(text+data) |
+|  ::++++0x005000
+|  ::|(bss)   ||(bss)   |
+|  ::++++0x006000
 |  ::::| /boot  |
 |  ::::++
 |  ::::::

Index: src/sys/arch/x68k/stand/xxboot/xxboot.ldscript
diff -u src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.6 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.7
--- src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.6	Sat Jan 18 07:25:12 2020
+++ src/sys/arch/x68k/stand/xxboot/xxboot.ldscript	Tue Jan 28 11:57:22 2020
@@ -35,6 +35,7 @@ SECTIONS
 edata  =  .;
 _edata  =  .;
   }
+  . = TEXTADDR + TEXTDATASIZE;
   .bss :
   {
 __bss_start = .;



CVS commit: src/sys/arch/x68k/stand

2020-01-28 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Jan 28 11:52:21 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S
src/sys/arch/x68k/stand/xxboot: boot.S

Log Message:
Use __bss_start rather than edata to point the beginning of .bss.
Currently the .bss is placed right after .data.  In that case, edata
points to the beginning of .bss so that there is no visible changes at
least currently.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x68k/stand/xxboot/boot.S

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/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.17 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.18
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.17	Sat Jan 18 06:34:29 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Tue Jan 28 11:52:21 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.17 2020/01/18 06:34:29 isaki Exp $
+| $NetBSD: boot.S,v 1.18 2020/01/28 11:52:21 isaki Exp $
 
 |
 | (1) IPL (or previous stage loader) loads first 1KB of this primary
@@ -67,7 +67,7 @@ ASENTRY_NOPROFILE(entry0)
 #define ASRELOC(var)	_RELOC(_ASM_LABEL(var))
 #define RELOC(var)	_RELOC(_C_LABEL(var))
 
-		lea	RELOC(edata),%a1
+		lea	RELOC(__bss_start),%a1
 		bra	_ASM_LABEL(entry)
 
 |	Disklabel= 404bytes

Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u src/sys/arch/x68k/stand/xxboot/boot.S:1.9 src/sys/arch/x68k/stand/xxboot/boot.S:1.10
--- src/sys/arch/x68k/stand/xxboot/boot.S:1.9	Sat Jan 18 06:34:30 2020
+++ src/sys/arch/x68k/stand/xxboot/boot.S	Tue Jan 28 11:52:21 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.9 2020/01/18 06:34:30 isaki Exp $
+| $NetBSD: boot.S,v 1.10 2020/01/28 11:52:21 isaki Exp $
 
 |
 | (1) IPL (or previous stage loader) loads first 1KB of this primary
@@ -69,7 +69,7 @@ ASENTRY_NOPROFILE(entry0)
 #define ASRELOC(var)	_RELOC(_ASM_LABEL(var))
 #define RELOC(var)	_RELOC(_C_LABEL(var))
 
-		lea	RELOC(edata),%a1
+		lea	RELOC(__bss_start),%a1
 		bra	_ASM_LABEL(entry)
 
 |	Disklabel= 404bytes



CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 07:25:12 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: Makefile boot_ufs.ldscript
src/sys/arch/x68k/stand/boot_ustar: Makefile boot_ustar.ldscript
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot xxboot.ldscript

Log Message:
Check whether the text+data+bss doesn't reach 0x6000 where secondary
bootloader should be.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.5 -r1.6 \
src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript

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/x68k/stand/boot_ufs/Makefile
diff -u src/sys/arch/x68k/stand/boot_ufs/Makefile:1.35 src/sys/arch/x68k/stand/boot_ufs/Makefile:1.36
--- src/sys/arch/x68k/stand/boot_ufs/Makefile:1.35	Sat Jan 18 06:44:23 2020
+++ src/sys/arch/x68k/stand/boot_ufs/Makefile	Sat Jan 18 07:25:11 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.35 2020/01/18 06:44:23 isaki Exp $
+#	$NetBSD: Makefile,v 1.36 2020/01/18 07:25:11 isaki Exp $
 
 NOMAN=		# defined
 
@@ -44,6 +44,7 @@ CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} -
 AFLAGS=	   ${CFLAGS:M-[ID]*}
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
+LINKFLAGS+=  --defsym=BOOT_TEXTADDR=$(BOOT_TEXT)
 
 .include "${.CURDIR}/../Makefile.booters"
 .include "${S}/../common/lib/libc/Makefile.inc"

Index: src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
diff -u src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.6 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.7
--- src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.6	Sat Jan 18 07:09:32 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript	Sat Jan 18 07:25:11 2020
@@ -48,3 +48,4 @@ SECTIONS
 
 ASSERT(first_kbyte - TEXTADDR <= 1024, "Error: first_kbyte exceeds 1KB");
 ASSERT(_edata - TEXTADDR <= 8192, "Error: text+data is too large to bootarea");
+ASSERT(_end <= BOOT_TEXTADDR, "Error: _end conflicts BOOT_TEXT");

Index: src/sys/arch/x68k/stand/boot_ustar/Makefile
diff -u src/sys/arch/x68k/stand/boot_ustar/Makefile:1.29 src/sys/arch/x68k/stand/boot_ustar/Makefile:1.30
--- src/sys/arch/x68k/stand/boot_ustar/Makefile:1.29	Sat Jan 18 06:44:23 2020
+++ src/sys/arch/x68k/stand/boot_ustar/Makefile	Sat Jan 18 07:25:11 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.29 2020/01/18 06:44:23 isaki Exp $
+#	$NetBSD: Makefile,v 1.30 2020/01/18 07:25:11 isaki Exp $
 
 NOMAN=		# defined
 
@@ -39,6 +39,7 @@ AFLAGS=	   ${CFLAGS:M-[ID]*}
 AFLAGS+=   -Wa,-march=m68000 -Wa,-mcpu=m68000
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
+LINKFLAGS+=  --defsym=BOOT_TEXTADDR=$(BOOT_TEXT)
 
 .include "${.CURDIR}/../Makefile.booters"
 .include "${S}/../common/lib/libc/Makefile.inc"

Index: src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.5 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.6
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.5	Sat Jan 18 06:44:23 2020
+++ src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript	Sat Jan 18 07:25:11 2020
@@ -48,3 +48,4 @@ SECTIONS
 
 ASSERT(first_kbyte - TEXTADDR <= 1024, "Error: first_kbyte exceeds 1KB");
 ASSERT(_edata - TEXTADDR <= 8192, "Error: text+data is too large to bootarea");
+ASSERT(_end <= BOOT_TEXTADDR, "Error: _end conflicts BOOT_TEXT");

Index: src/sys/arch/x68k/stand/xxboot/Makefile.xxboot
diff -u src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.10 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.11
--- src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.10	Sat Jan 18 06:44:23 2020
+++ src/sys/arch/x68k/stand/xxboot/Makefile.xxboot	Sat Jan 18 07:25:12 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.xxboot,v 1.10 2020/01/18 06:44:23 isaki Exp $
+#	$NetBSD: Makefile.xxboot,v 1.11 2020/01/18 07:25:12 isaki Exp $
 
 NOMAN=		# defined
 
@@ -41,6 +41,7 @@ CPPFLAGS+= -I$M/stand/libiocs -I$M/stand
 AFLAGS=	   ${CFLAGS:M-[ID]*}
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
+LINKFLAGS+=  --defsym=BOOT_TEXTADDR=$(BOOT_TEXT)
 LINKFLAGS+=  --defsym=TEXTDATASIZE=$(TEXTDATASIZE)
 LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
 LIBSA!=	  cd $M/stand/libsa && ${PRINTOBJDIR}

Index: src/sys/arch/x68k/stand/xxboot/xxboot.ldscript
diff -u src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.5 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.6
--- src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.5	Sat Jan 18 07:09:32 2020
+++ src/sys/arch/x68k/stand/xxboot/xx

CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 07:09:32 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot_ufs.ldscript
src/sys/arch/x68k/stand/xxboot: xxboot.ldscript

Log Message:
Make .bss follows .data to detect size restriction easier.
Previously, if text+data exceeds the restricted size, it will conflict
with manually fixed .bss area and ldscript makes it an error.
By this change, ASSERT() can detect it.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript

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/x68k/stand/boot_ufs/boot_ufs.ldscript
diff -u src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.5 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.6
--- src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.5	Sat Jan 18 06:44:23 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript	Sat Jan 18 07:09:32 2020
@@ -35,7 +35,6 @@ SECTIONS
 edata  =  .;
 _edata  =  .;
   }
-  . = TEXTADDR + 0x2000;
   .bss :
   {
 __bss_start = .;
@@ -48,3 +47,4 @@ SECTIONS
 }
 
 ASSERT(first_kbyte - TEXTADDR <= 1024, "Error: first_kbyte exceeds 1KB");
+ASSERT(_edata - TEXTADDR <= 8192, "Error: text+data is too large to bootarea");

Index: src/sys/arch/x68k/stand/xxboot/xxboot.ldscript
diff -u src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.4 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.5
--- src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.4	Sat Jan 18 06:44:23 2020
+++ src/sys/arch/x68k/stand/xxboot/xxboot.ldscript	Sat Jan 18 07:09:32 2020
@@ -35,7 +35,6 @@ SECTIONS
 edata  =  .;
 _edata  =  .;
   }
-  . = TEXTADDR + TEXTDATASIZE;
   .bss :
   {
 __bss_start = .;
@@ -48,3 +47,5 @@ SECTIONS
 }
 
 ASSERT(first_kbyte - TEXTADDR <= 1024, "Error: first_kbyte exceeds 1KB");
+ASSERT(_edata - TEXTADDR <= TEXTDATASIZE,
+"Error: text+data is too large to bootarea");



CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 06:44:23 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: Makefile boot_ufs.ldscript
src/sys/arch/x68k/stand/boot_ustar: Makefile boot_ustar.ldscript
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot xxboot.ldscript

Log Message:
Use ASSERT() in ldscript to check first_kbyte (etc) restrictions,
rather than complicated shell expressions in Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.4 -r1.5 \
src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript

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/x68k/stand/boot_ufs/Makefile
diff -u src/sys/arch/x68k/stand/boot_ufs/Makefile:1.34 src/sys/arch/x68k/stand/boot_ufs/Makefile:1.35
--- src/sys/arch/x68k/stand/boot_ufs/Makefile:1.34	Sat Jan 18 06:34:29 2020
+++ src/sys/arch/x68k/stand/boot_ufs/Makefile	Sat Jan 18 06:44:23 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.34 2020/01/18 06:34:29 isaki Exp $
+#	$NetBSD: Makefile,v 1.35 2020/01/18 06:44:23 isaki Exp $
 
 NOMAN=		# defined
 
@@ -42,29 +42,15 @@ CPPFLAGS+= -DSCSI_ADHOC_BOOTPART
 CPPFLAGS+= -DUSE_FFS -DUSE_LFS -DUSE_UFS1 -DUSE_UFS2
 CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} -I${S} -I. -D_STANDALONE
 AFLAGS=	   ${CFLAGS:M-[ID]*}
-LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M
+LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
 
 .include "${.CURDIR}/../Makefile.booters"
 .include "${S}/../common/lib/libc/Makefile.inc"
 
-CLEANFILES+=	$(PROG).x $(PROG).map
-
 
 $(PROG): $(OBJS)
 	${_MKTARGET_LINK}
-	:
-	: Note:	"relocation truncated to fit: R_68K_16" messages are expected.
-	:	Other errors are fatal.
-	:
-	$(LD) $(LINKFLAGS) -o $(PROG).x $(OBJS) $(LDADD) >$(PROG).map
-	@grep first_kbyte $(PROG).map
-	@if [ `${TOOL_AWK}		   \
-	'/first_kbyte/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'	   \
-	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
-	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
-	exit 1;			   \
-	fi
-	mv -f $(PROG).x $(PROG)
+	$(LD) $(LINKFLAGS) -o $(PROG) $(OBJS) $(LDADD)
 
 .include 

Index: src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
diff -u src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.4 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.5
--- src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.4	Sat Jan 18 06:03:03 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript	Sat Jan 18 06:44:23 2020
@@ -46,3 +46,5 @@ SECTIONS
   }
   /DISCARD/ : { *(.ident) *(.stab) *(.stabstr) }
 }
+
+ASSERT(first_kbyte - TEXTADDR <= 1024, "Error: first_kbyte exceeds 1KB");

Index: src/sys/arch/x68k/stand/boot_ustar/Makefile
diff -u src/sys/arch/x68k/stand/boot_ustar/Makefile:1.28 src/sys/arch/x68k/stand/boot_ustar/Makefile:1.29
--- src/sys/arch/x68k/stand/boot_ustar/Makefile:1.28	Sat Jan 18 06:34:30 2020
+++ src/sys/arch/x68k/stand/boot_ustar/Makefile	Sat Jan 18 06:44:23 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.28 2020/01/18 06:34:30 isaki Exp $
+#	$NetBSD: Makefile,v 1.29 2020/01/18 06:44:23 isaki Exp $
 
 NOMAN=		# defined
 
@@ -37,30 +37,15 @@ CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} -
 CFLAGS+=   -m68000
 AFLAGS=	   ${CFLAGS:M-[ID]*}
 AFLAGS+=   -Wa,-march=m68000 -Wa,-mcpu=m68000
-LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M
+LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
 
 .include "${.CURDIR}/../Makefile.booters"
 .include "${S}/../common/lib/libc/Makefile.inc"
 
-CLEANFILES+=	${PROG}.x $(PROG).map
-
 
 ${PROG}: $(OBJS)
 	${_MKTARGET_LINK}
-	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDADD) > $(PROG).map
-	@grep first_kbyte $(PROG).map
-	@if [ `${TOOL_AWK}		   \
-	'/first_kbyte/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'	   \
-	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
-	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
-	rm $(PROG) ; exit 1; 	   \
-	fi
-	@if [ `${TOOL_AWK}		   \
-	'/_edata/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'	   \
-	$(PROG).map | ${TOOL_M4} -` -gt 8192 ];			   \
-	then echo '$(BOOT): text+data is too large';			   \
-	rm $(PROG) ; exit 1; 	   \
-	fi
+	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDADD)
 
 .include 

Index: src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.4 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.5
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.4	Sat Jan 18 06:

CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 06:34:30 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: Makefile boot.S
src/sys/arch/x68k/stand/boot_ustar: Makefile
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot boot.S

Log Message:
Change primary bootloader's load address from 0x0f to 0x003000.
- Moving addresses closer eliminates bunch of this linker errors:
in function `entry0':
relocation truncated to fit: R_68K_16 against `edata'+8000
:
- By this change, harmful -noinhibit-exec option can also be removed.
  Finally, we can break the builds when assemble error occurs!
- Load address of secondary is 0x6000, so that this change limits
  text+data+bss 12KB or less.  Current actual size is 5~7KB.
  I think it should be fine.
- cd9660 can have up to 30KB text+data in its bootarea.  Even in this
  case, this change limits text+data+bss 12KB or less (currently, it's
  about 6KB).  However, I take breaking the builds on errors rather than
  future size limitation.
There is no user visible changes or interface changes.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot \
src/sys/arch/x68k/stand/xxboot/boot.S

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/x68k/stand/boot_ufs/Makefile
diff -u src/sys/arch/x68k/stand/boot_ufs/Makefile:1.33 src/sys/arch/x68k/stand/boot_ufs/Makefile:1.34
--- src/sys/arch/x68k/stand/boot_ufs/Makefile:1.33	Sat Jan 18 05:46:26 2020
+++ src/sys/arch/x68k/stand/boot_ufs/Makefile	Sat Jan 18 06:34:29 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.33 2020/01/18 05:46:26 isaki Exp $
+#	$NetBSD: Makefile,v 1.34 2020/01/18 06:34:29 isaki Exp $
 
 NOMAN=		# defined
 
@@ -11,7 +11,7 @@ VERSION!=	${TOOL_AWK} -F: '$$1 ~ /^[0-9.
 NEWVERSWHAT=	"${BOOT}"
 
 # text and bss addresses
-TEXT=		0x0f	# Primary (me)
+TEXT=		0x003000	# Primary (me)
 BOOT_TEXT=	0x006000	# Secondary (/boot)
 
 PROG=		xx$(BOOT)
@@ -44,7 +44,6 @@ CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} -
 AFLAGS=	   ${CFLAGS:M-[ID]*}
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M
 LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
-LINKFLAGS+=  -noinhibit-exec	# XXX
 
 .include "${.CURDIR}/../Makefile.booters"
 .include "${S}/../common/lib/libc/Makefile.inc"

Index: src/sys/arch/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.16 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.17
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.16	Sat Jan 18 05:56:51 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Sat Jan 18 06:34:29 2020
@@ -2,14 +2,14 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.16 2020/01/18 05:56:51 isaki Exp $
+| $NetBSD: boot.S,v 1.17 2020/01/18 06:34:29 isaki Exp $
 
 |
 | (1) IPL (or previous stage loader) loads first 1KB of this primary
 | bootloader to (*).  (*) is 0x2000 (from FD) or 0x2400 (from SASI/SCSI).
 |
 | (2) The first 1KB loads full primary bootloader (including first 1KB) from
-| the boot partition to 0xf.  And jump to there.
+| the boot partition to 0x3000.  And jump to there.
 |
 | (3) The full primary bootloader loads the secondary bootloader known as
 | /boot from its filesystem to 0x6000.  And jump to there.
@@ -24,26 +24,24 @@
 |  | first 1KB  || first 1KB  || first 1KB  |
 |  ++++++(*)+0x400
 |  ::::::
+|  ::++++0x003000
+|  ::|full primary||full primary|
+|  ::|boot loader ||boot loader |
+|  ::++++
+|  ::::::
 |  ::::++0x006000
 |  ::::| /boot  |
 |  ::::++
 |  ::::::
 |  ~~~~~~
 |  ::::<-SP::<-SP
-|  ::++++0x0f
-|  ::|full primary||full primary|
-|  ::|boot loader ||boot loader |
-|  ::++++
+|  + - - - - - -++ - - - - - -++ - - - - - -+0x10
 |  ::::::
 |
 
 #include 
 #include "iocscall.h"
 
-#define 

CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 06:03:03 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot: boot.ldscript
src/sys/arch/x68k/stand/boot_ufs: boot_ufs.ldscript
src/sys/arch/x68k/stand/boot_ustar: boot_ustar.ldscript
src/sys/arch/x68k/stand/xxboot: xxboot.ldscript

Log Message:
Remove commented out ALIGN() operation.
It looks unnecessary and has never been used.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x68k/stand/boot/boot.ldscript
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
cvs rdiff -u -r1.3 -r1.4 \
src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript

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/x68k/stand/boot/boot.ldscript
diff -u src/sys/arch/x68k/stand/boot/boot.ldscript:1.8 src/sys/arch/x68k/stand/boot/boot.ldscript:1.9
--- src/sys/arch/x68k/stand/boot/boot.ldscript:1.8	Sat Jan 18 05:41:48 2020
+++ src/sys/arch/x68k/stand/boot/boot.ldscript	Sat Jan 18 06:03:02 2020
@@ -28,7 +28,6 @@ SECTIONS
 etext = .;
 _etext = .;
   }
-/*  . = ALIGN(0x2000); */
   .data :
   {
 /* The first three sections are for SunOS dynamic linking.  */

Index: src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
diff -u src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.3 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.4
--- src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.3	Sat Jan 18 05:41:48 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript	Sat Jan 18 06:03:03 2020
@@ -23,7 +23,6 @@ SECTIONS
 etext = .;
 _etext = .;
   }
-/*  . = ALIGN(0x2000); */
   .data :
   {
 /* The first three sections are for SunOS dynamic linking.  */

Index: src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.3 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.4
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.3	Sat Jan 18 05:41:48 2020
+++ src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript	Sat Jan 18 06:03:03 2020
@@ -23,7 +23,6 @@ SECTIONS
 etext = .;
 _etext = .;
   }
-/*  . = ALIGN(0x2000); */
   .data :
   {
 /* The first three sections are for SunOS dynamic linking.  */

Index: src/sys/arch/x68k/stand/xxboot/xxboot.ldscript
diff -u src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.2 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.3
--- src/sys/arch/x68k/stand/xxboot/xxboot.ldscript:1.2	Sat Jan 18 05:41:49 2020
+++ src/sys/arch/x68k/stand/xxboot/xxboot.ldscript	Sat Jan 18 06:03:03 2020
@@ -23,7 +23,6 @@ SECTIONS
 etext = .;
 _etext = .;
   }
-/*  . = ALIGN(0x2000); */
   .data :
   {
 /* The first three sections are for SunOS dynamic linking.  */



CVS commit: src/sys/arch/x68k/stand/boot_ustar

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 06:00:04 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ustar: boot_ustar.S

Log Message:
Check whether MPU >= 68020.
Because current secondary bootloader assumes that.
This will display a reasonable error message instead of "Error occurs,
please reset" (IPL message) when you try sysinst*.fs on X68000.

XXX secondary bootloader (/boot) should not assume mpu regardless of
whether primary bootloader has checked mpu. (?)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S

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/x68k/stand/boot_ustar/boot_ustar.S
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.11 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.12
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.11	Sat Jan 18 05:07:34 2020
+++ src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S	Sat Jan 18 06:00:04 2020
@@ -3,7 +3,7 @@
 | ITOH Yasufumi
 |	  mino...@netbsd.org
 |
-| $NetBSD: boot_ustar.S,v 1.11 2020/01/18 05:07:34 isaki Exp $
+| $NetBSD: boot_ustar.S,v 1.12 2020/01/18 06:00:04 isaki Exp $
 
 | supports floppy only
 
@@ -56,6 +56,18 @@ ASENTRY_NOPROFILE(entry)
 		moveq	#0x10,%d1
 		IOCS(__CRTMOD)
 
+		| We use 68020 instructions, and check MPU beforehand.
+		| Here "moveql #-1,%d0" = 0x70ff, and subsequent moveb loads
+		|   0xff if MPU <= 010 (chkmpu+2 + %d0.w)
+		|   0x70 if MPU >= 020 (chkmpu+2 + %d0.w*2).
+		| This is a move, not a tst instruction because tst with
+		| pc-relative is not available on 000/010.
+chkmpu:
+		moveql	#-1,%d0
+		.word	0x103b, 0x02fe	| moveb	%pc@(chkmpu+2,%d0:W:2),%d0
+		jpl	mpuok		| MC68020 or later
+		BOOT_ERROR("MPU 68000?");
+mpuok:
 		|
 		| SASI or Floppy
 		|



CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 05:56:51 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S
src/sys/arch/x68k/stand/xxboot: boot.S

Log Message:
Typo in comment. s/availble/available/


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x68k/stand/xxboot/boot.S

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/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.15 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.16
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.15	Sat Jan 18 05:48:31 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Sat Jan 18 05:56:51 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.15 2020/01/18 05:48:31 isaki Exp $
+| $NetBSD: boot.S,v 1.16 2020/01/18 05:56:51 isaki Exp $
 
 |
 | (1) IPL (or previous stage loader) loads first 1KB of this primary
@@ -99,7 +99,7 @@ clrbss:		clrb	%a1@+
 		|	if MPU <= 010	loads 0x49,
 		|	if MPU >= 020	loads 0x90.
 		| This is a move, not a tst instruction
-		| because pc-relative tsts are not availble on 000/010.
+		| because pc-relative tsts are not available on 000/010.
 chkmpu:		moveb	%pc@(clrbss-chkmpu-2:B,%d0:W:2),%d0	| 103B 02xx
 		jmi	mpuok		| MC68020 or later
 		BOOT_ERROR("MPU 68000?")

Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u src/sys/arch/x68k/stand/xxboot/boot.S:1.7 src/sys/arch/x68k/stand/xxboot/boot.S:1.8
--- src/sys/arch/x68k/stand/xxboot/boot.S:1.7	Sat Jan 18 05:48:31 2020
+++ src/sys/arch/x68k/stand/xxboot/boot.S	Sat Jan 18 05:56:51 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.7 2020/01/18 05:48:31 isaki Exp $
+| $NetBSD: boot.S,v 1.8 2020/01/18 05:56:51 isaki Exp $
 
 |
 | (1) IPL (or previous stage loader) loads first 1KB of this primary
@@ -101,7 +101,7 @@ clrbss:		clrb	%a1@+
 		|	if MPU <= 010	loads 0x49,
 		|	if MPU >= 020	loads 0x90.
 		| This is a move, not a tst instruction
-		| because pc-relative tsts are not availble on 000/010.
+		| because pc-relative tsts are not available on 000/010.
 chkmpu:		moveb	%pc@(clrbss-chkmpu-2:B,%d0:W:2),%d0	| 103B 02xx
 		jmi	mpuok		| MC68020 or later
 		BOOT_ERROR("MPU 68000?")



CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 05:48:31 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S
src/sys/arch/x68k/stand/xxboot: boot.S

Log Message:
Add comment and figure of address map.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x68k/stand/xxboot/boot.S

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/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.14 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.15
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.14	Sat Jan 18 05:07:34 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Sat Jan 18 05:48:31 2020
@@ -2,7 +2,40 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.14 2020/01/18 05:07:34 isaki Exp $
+| $NetBSD: boot.S,v 1.15 2020/01/18 05:48:31 isaki Exp $
+
+|
+| (1) IPL (or previous stage loader) loads first 1KB of this primary
+| bootloader to (*).  (*) is 0x2000 (from FD) or 0x2400 (from SASI/SCSI).
+|
+| (2) The first 1KB loads full primary bootloader (including first 1KB) from
+| the boot partition to 0xf.  And jump to there.
+|
+| (3) The full primary bootloader loads the secondary bootloader known as
+| /boot from its filesystem to 0x6000.  And jump to there.
+|
+| Therefore, The first 1KB must be relocatable.
+| The first 1KB must be smaller than or equal to 1024 bytes.
+|
+|   (1) ->(2) ->(3)
+|  ++++++0x00
+|  ::::::
+|  ++++++(*)
+|  | first 1KB  || first 1KB  || first 1KB  |
+|  ++++++(*)+0x400
+|  ::::::
+|  ::::++0x006000
+|  ::::| /boot  |
+|  ::::++
+|  ::::::
+|  ~~~~~~
+|  ::::<-SP::<-SP
+|  ::++++0x0f
+|  ::|full primary||full primary|
+|  ::|boot loader ||boot loader |
+|  ::++++
+|  ::::::
+|
 
 #include 
 #include "iocscall.h"
@@ -28,9 +61,7 @@ ASENTRY_NOPROFILE(top)
 		.word	0x8e9e,0x82c9,0x82cd,0x8cbb
 		.word	0x8ec0,0x93a6,0x94f0,0x8149
 		.word	0
-| 0x2000 (FD), 0x2400 (SASI/SCSI) (¤â¤·¤¯¤Ï 0x0f)
 | d4 ¤Ë¤Ï¤¹¤Ç¤Ë SCSI ID ¤¬Æþ¤Ã¤Æ¤¤¤ë
-| ¤³¤³¤«¤é jmp ¤Þ¤Ç¤Ï¥ê¥í¥±¡¼¥¿¥Ö¥ë¤Ë½ñ¤«¤Í¤Ð¤Ê¤é¤Ê¤¤¡£
 ASENTRY_NOPROFILE(entry0)
 		moveml	%d0-%d7/%a0-%a7,_C_LABEL(startregs)
 		lea	BASEPTR_A:l,%a5		| set base ptr

Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u src/sys/arch/x68k/stand/xxboot/boot.S:1.6 src/sys/arch/x68k/stand/xxboot/boot.S:1.7
--- src/sys/arch/x68k/stand/xxboot/boot.S:1.6	Sat Jan 18 05:07:34 2020
+++ src/sys/arch/x68k/stand/xxboot/boot.S	Sat Jan 18 05:48:31 2020
@@ -2,7 +2,40 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.6 2020/01/18 05:07:34 isaki Exp $
+| $NetBSD: boot.S,v 1.7 2020/01/18 05:48:31 isaki Exp $
+
+|
+| (1) IPL (or previous stage loader) loads first 1KB of this primary
+| bootloader to (*).  (*) is 0x2000 (from FD) or 0x2400 (from SASI/SCSI).
+|
+| (2) The first 1KB loads full primary bootloader (including first 1KB) from
+| the boot partition to 0xf.  And jump to there.
+|
+| (3) The full primary bootloader loads the secondary bootloader known as
+| /boot from its filesystem to 0x6000.  And jump to there.
+|
+| Therefore, The first 1KB must be relocatable.
+| The first 1KB must be smaller than or equal to 1024 bytes.
+|
+|   (1) ->(2) ->(3)
+|  ++++++0x00
+|  ::::::
+|  ++++++(*)
+|  | first 1KB  || first 1KB  || first 1KB  |
+|  ++++++(*)+0x400
+|  ::::::
+|  ::::++0x006000
+|  ::::| /boot  |
+|  ::::++
+|  ::::::
+|  ~~~

CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 05:46:26 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot: Makefile
src/sys/arch/x68k/stand/boot_ufs: Makefile
src/sys/arch/x68k/stand/boot_ustar: Makefile
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot

Log Message:
Add 0x prefix when defining variables, not when using it.
This was necessary for bc(1) but it's no longer necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x68k/stand/boot/Makefile
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot

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/x68k/stand/boot/Makefile
diff -u src/sys/arch/x68k/stand/boot/Makefile:1.32 src/sys/arch/x68k/stand/boot/Makefile:1.33
--- src/sys/arch/x68k/stand/boot/Makefile:1.32	Sat Jan 18 05:41:48 2020
+++ src/sys/arch/x68k/stand/boot/Makefile	Sat Jan 18 05:46:25 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.32 2020/01/18 05:41:48 isaki Exp $
+#	$NetBSD: Makefile,v 1.33 2020/01/18 05:46:25 isaki Exp $
 
 NOMAN=		# defined
 
@@ -11,7 +11,7 @@ VERSION!=	${TOOL_AWK} -F: '$$1 ~ /^[0-9.
 NEWVERSWHAT=	"${BOOT}"
 
 # text address
-TEXT=		006000
+TEXT=		0x6000
 
 # RTC offset for netboot (XXX hardcoded for JST-9)
 RTC_OFFSET=	-540
@@ -34,7 +34,7 @@ COMMONDIR=	$M/stand/common
 CPPFLAGS+=	-nostdinc -I$S -I${.OBJDIR} -I$M/stand/libsa
 CPPFLAGS+=	-I$M/stand/libiocs -I${COMMONDIR}
 CPPFLAGS+=	-D_STANDALONE -DHEAP_VARIABLE
-CPPFLAGS+=	-DTEXTADDR="0x${TEXT}" 
+CPPFLAGS+=	-DTEXTADDR="${TEXT}"
 CPPFLAGS+=	-DBOOT=\"${BOOT}\" -DBOOT_VERS=\"${VERSION}\"
 CPPFLAGS+=	-DLIBSA_ENABLE_LS_OP
 CPPFLAGS+=	-DRTC_OFFSET=${RTC_OFFSET}
@@ -42,7 +42,7 @@ CPPFLAGS+=	-DSUPPORT_BOOTP -DSUPPORT_DHC
 #CPPFLAGS+=	-DDEBUG
 CFLAGS=		-Wno-main -Os -m68020-60
 LINKFLAGS=	-N -static -T ${.CURDIR}/../boot/boot.ldscript
-LINKFLAGS+=	--defsym=TEXTADDR=0x$(TEXT)
+LINKFLAGS+=	--defsym=TEXTADDR=$(TEXT)
 ELF2AOUT_OPTS=	-O
 LIBIOCS!=	cd $M/stand/libiocs && ${PRINTOBJDIR}
 LIBSA!=		cd $M/stand/libsa && ${PRINTOBJDIR}

Index: src/sys/arch/x68k/stand/boot_ufs/Makefile
diff -u src/sys/arch/x68k/stand/boot_ufs/Makefile:1.32 src/sys/arch/x68k/stand/boot_ufs/Makefile:1.33
--- src/sys/arch/x68k/stand/boot_ufs/Makefile:1.32	Sat Jan 18 05:41:48 2020
+++ src/sys/arch/x68k/stand/boot_ufs/Makefile	Sat Jan 18 05:46:26 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.32 2020/01/18 05:41:48 isaki Exp $
+#	$NetBSD: Makefile,v 1.33 2020/01/18 05:46:26 isaki Exp $
 
 NOMAN=		# defined
 
@@ -10,9 +10,9 @@ VERSION!=	${TOOL_AWK} -F: '$$1 ~ /^[0-9.
 			END { print it }' ${VERSIONFILE}
 NEWVERSWHAT=	"${BOOT}"
 
-# text and bss addresses in hex
-TEXT=		0f		# Primary (me)
-BOOT_TEXT=	006000		# Secondary (/boot)
+# text and bss addresses
+TEXT=		0x0f	# Primary (me)
+BOOT_TEXT=	0x006000	# Secondary (/boot)
 
 PROG=		xx$(BOOT)
 LINKS=		${BINDIR}/xx$(BOOT) ${BINDIR}/sd$(BOOT)
@@ -35,7 +35,7 @@ SRCS+=	exec_image.S memset.S strcmp.S
 CFLAGS=	-Os -fomit-frame-pointer -fno-unwind-tables
 CFLAGS+= -m68020-60
 CFLAGS+= -W -Wall -Wstrict-prototypes -Wmissing-prototypes
-CPPFLAGS+= -DTEXTADDR="0x$(TEXT)" -DBOOT_TEXTADDR="0x$(BOOT_TEXT)"
+CPPFLAGS+= -DTEXTADDR="$(TEXT)" -DBOOT_TEXTADDR="$(BOOT_TEXT)"
 CPPFLAGS+= -DBOOT=\"$(BOOT)\" -DBOOT_VERS=\"$(VERSION)\"
 CPPFLAGS+= -DSCSI_ADHOC_BOOTPART
 #CPPFLAGS+= -DBOOT_DEBUG
@@ -43,7 +43,7 @@ CPPFLAGS+= -DUSE_FFS -DUSE_LFS -DUSE_UFS
 CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} -I${S} -I. -D_STANDALONE
 AFLAGS=	   ${CFLAGS:M-[ID]*}
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M
-LINKFLAGS+=  --defsym=TEXTADDR=0x$(TEXT)
+LINKFLAGS+=  --defsym=TEXTADDR=$(TEXT)
 LINKFLAGS+=  -noinhibit-exec	# XXX
 
 .include "${.CURDIR}/../Makefile.booters"
@@ -61,7 +61,7 @@ $(PROG): $(OBJS)
 	$(LD) $(LINKFLAGS) -o $(PROG).x $(OBJS) $(LDADD) >$(PROG).map
 	@grep first_kbyte $(PROG).map
 	@if [ `${TOOL_AWK}		   \
-	'/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
+	'/first_kbyte/ {print "eval(eval("$$1")-eval('$(TEXT)'))"}'	   \
 	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
 	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
 	exit 1;			   \

Index: src/sys/arch/x68k/stand/boot_ustar/Makefile
diff -u src/sys/arch/x68k/stand/boot_ustar/Makefile:1.26 src/sys/arch/x68k/stand/boot_ustar/Makefile:1.27
--- src/sys/arch/x68k/stand/boot_ustar/Makefile:1.26	Sat Jan 18 05:41:48 2020
+++ src/sys/arch/x68k/stand/boot_ustar/Makefile	Sat Jan 18 05:46:26 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.26 2020/01/18 05:41:48 isaki Exp $
+#	$NetBSD: Makefile,v 1.27 2020/01/18 05:46:26 isaki Exp $
 
 NOMAN=		# defined
 
@@ -10,9 +10,9 @@ VERSION!=	${TOOL_AWK} -F: '$$1 ~ /^[0-9.
 			END { print it }' ${VERSIONFILE}
 NEWVERSWHAT=	"${BOOT}"
 
-# tex

CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 05:41:49 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot: Makefile boot.ldscript
src/sys/arch/x68k/stand/boot_ufs: Makefile boot_ufs.ldscript
src/sys/arch/x68k/stand/boot_ustar: Makefile boot_ustar.ldscript
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot xxboot.ldscript

Log Message:
Pass address constants from Makefile to ldscript.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x68k/stand/boot/Makefile
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x68k/stand/boot/boot.ldscript
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.2 -r1.3 \
src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x68k/stand/xxboot/xxboot.ldscript

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/x68k/stand/boot/Makefile
diff -u src/sys/arch/x68k/stand/boot/Makefile:1.31 src/sys/arch/x68k/stand/boot/Makefile:1.32
--- src/sys/arch/x68k/stand/boot/Makefile:1.31	Fri Jun 14 14:15:53 2019
+++ src/sys/arch/x68k/stand/boot/Makefile	Sat Jan 18 05:41:48 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.31 2019/06/14 14:15:53 isaki Exp $
+#	$NetBSD: Makefile,v 1.32 2020/01/18 05:41:48 isaki Exp $
 
 NOMAN=		# defined
 
@@ -42,6 +42,7 @@ CPPFLAGS+=	-DSUPPORT_BOOTP -DSUPPORT_DHC
 #CPPFLAGS+=	-DDEBUG
 CFLAGS=		-Wno-main -Os -m68020-60
 LINKFLAGS=	-N -static -T ${.CURDIR}/../boot/boot.ldscript
+LINKFLAGS+=	--defsym=TEXTADDR=0x$(TEXT)
 ELF2AOUT_OPTS=	-O
 LIBIOCS!=	cd $M/stand/libiocs && ${PRINTOBJDIR}
 LIBSA!=		cd $M/stand/libsa && ${PRINTOBJDIR}

Index: src/sys/arch/x68k/stand/boot/boot.ldscript
diff -u src/sys/arch/x68k/stand/boot/boot.ldscript:1.7 src/sys/arch/x68k/stand/boot/boot.ldscript:1.8
--- src/sys/arch/x68k/stand/boot/boot.ldscript:1.7	Mon Dec 31 19:25:46 2018
+++ src/sys/arch/x68k/stand/boot/boot.ldscript	Sat Jan 18 05:41:48 2020
@@ -10,7 +10,7 @@ SEARCH_DIR(/usr/lib);
 PROVIDE (__stack = 0);
 SECTIONS
 {
-  . = 0x6000;
+  . = TEXTADDR;
   .text :
   {
 CREATE_OBJECT_SYMBOLS

Index: src/sys/arch/x68k/stand/boot_ufs/Makefile
diff -u src/sys/arch/x68k/stand/boot_ufs/Makefile:1.31 src/sys/arch/x68k/stand/boot_ufs/Makefile:1.32
--- src/sys/arch/x68k/stand/boot_ufs/Makefile:1.31	Thu Jan 16 13:15:47 2020
+++ src/sys/arch/x68k/stand/boot_ufs/Makefile	Sat Jan 18 05:41:48 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.31 2020/01/16 13:15:47 isaki Exp $
+#	$NetBSD: Makefile,v 1.32 2020/01/18 05:41:48 isaki Exp $
 
 NOMAN=		# defined
 
@@ -43,6 +43,7 @@ CPPFLAGS+= -DUSE_FFS -DUSE_LFS -DUSE_UFS
 CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} -I${S} -I. -D_STANDALONE
 AFLAGS=	   ${CFLAGS:M-[ID]*}
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M
+LINKFLAGS+=  --defsym=TEXTADDR=0x$(TEXT)
 LINKFLAGS+=  -noinhibit-exec	# XXX
 
 .include "${.CURDIR}/../Makefile.booters"

Index: src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript
diff -u src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.2 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.3
--- src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript:1.2	Sat Nov 24 16:18:44 2001
+++ src/sys/arch/x68k/stand/boot_ufs/boot_ufs.ldscript	Sat Jan 18 05:41:48 2020
@@ -6,7 +6,7 @@ SEARCH_DIR(/usr/lib);
 PROVIDE (__stack = 0);
 SECTIONS
 {
-  . = 0x0f;
+  . = TEXTADDR;
   .text :
   {
 CREATE_OBJECT_SYMBOLS
@@ -36,7 +36,7 @@ SECTIONS
 edata  =  .;
 _edata  =  .;
   }
-  . = 0x0f2000;
+  . = TEXTADDR + 0x2000;
   .bss :
   {
 __bss_start = .;

Index: src/sys/arch/x68k/stand/boot_ustar/Makefile
diff -u src/sys/arch/x68k/stand/boot_ustar/Makefile:1.25 src/sys/arch/x68k/stand/boot_ustar/Makefile:1.26
--- src/sys/arch/x68k/stand/boot_ustar/Makefile:1.25	Thu Jan 16 13:15:47 2020
+++ src/sys/arch/x68k/stand/boot_ustar/Makefile	Sat Jan 18 05:41:48 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.25 2020/01/16 13:15:47 isaki Exp $
+#	$NetBSD: Makefile,v 1.26 2020/01/18 05:41:48 isaki Exp $
 
 NOMAN=		# defined
 
@@ -38,6 +38,7 @@ CFLAGS+=   -m68000
 AFLAGS=	   ${CFLAGS:M-[ID]*}
 AFLAGS+=   -Wa,-march=m68000 -Wa,-mcpu=m68000
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/${BOOT}.ldscript -M
+LINKFLAGS+=  --defsym=TEXTADDR=0x$(TEXT)
 LINKFLAGS+=  -noinhibit-exec	# XXX
 
 .include "${.CURDIR}/../Makefile.booters"

Index: src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.2 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.3
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript:1.2	Sat Nov 24 16:18:45 2001
+++ src/sys/arch/x68k/stand/boot_ustar/boot_ustar.ldscript	Sat Jan 18 05:41:48 2020
@@ -6,7 +6,7 @@ SEARCH_DIR(/

CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 05:07:34 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S version
src/sys/arch/x68k/stand/boot_ustar: boot_ustar.S version
src/sys/arch/x68k/stand/libiocs: iocscall.h
src/sys/arch/x68k/stand/xxboot: boot.S version

Log Message:
Initialize the screen in all primary bootloaders.
- Some IPL (or boot selector) don't do it, but current secondary bootloader
  expects the screen to be initialized to display logo.
  To keep messages (like version signature) displayed by primary bootloader,
  this initialization should be done early in all primary bootloaders.
- For boot_ustar.S, relocates some registers to save bootinfo (%d0).
- Bumps version.

Confirmed on X68030+060turbo and my X68030.  This problem was found on
X68030+060turbo at NetBSD booth in OSC 2011 Hiroshima (8+ years ago).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x68k/stand/boot_ufs/version
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x68k/stand/boot_ustar/version
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x68k/stand/libiocs/iocscall.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x68k/stand/xxboot/boot.S
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x68k/stand/xxboot/version

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/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.13 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.14
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.13	Thu Jan 16 13:37:26 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Sat Jan 18 05:07:34 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.13 2020/01/16 13:37:26 isaki Exp $
+| $NetBSD: boot.S,v 1.14 2020/01/18 05:07:34 isaki Exp $
 
 #include 
 #include "iocscall.h"
@@ -290,6 +290,14 @@ first_kbyte:
 |	The latter text+data part is not accessible at the first boot time.
 |	PC-relative can be used from here.
 |
+		| Initialize the screen here.  Some IPL (060turbo ROM or
+		| genuine boot selector) don't initialize the screen.
+		| Such initialization should be done as early as possible
+		| but it's too severe to place it in first_kbyte area.
+		| Therefore do it here.
+		moveq	#0x10,%d1
+		IOCS(__CRTMOD)
+
 		jmp	_C_LABEL(bootufs)	| 0x0F ¤ËÈô¤ó¤Ç¤æ¤¯
 
 		.word	0

Index: src/sys/arch/x68k/stand/boot_ufs/version
diff -u src/sys/arch/x68k/stand/boot_ufs/version:1.3 src/sys/arch/x68k/stand/boot_ufs/version:1.4
--- src/sys/arch/x68k/stand/boot_ufs/version:1.3	Sun Jan 12 13:51:12 2020
+++ src/sys/arch/x68k/stand/boot_ufs/version	Sat Jan 18 05:07:34 2020
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.3 2020/01/12 13:51:12 isaki Exp $
+$NetBSD: version,v 1.4 2020/01/18 05:07:34 isaki Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -9,3 +9,4 @@ is taken as the current.
 	/boot.
 	Add LFS support (not tested yet).
 1.1:	Add LFSv2 support
+1.2:	Initialize the screen.

Index: src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.10 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.11
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.10	Thu Jan 16 13:37:26 2020
+++ src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S	Sat Jan 18 05:07:34 2020
@@ -3,7 +3,7 @@
 | ITOH Yasufumi
 |	  mino...@netbsd.org
 |
-| $NetBSD: boot_ustar.S,v 1.10 2020/01/16 13:37:26 isaki Exp $
+| $NetBSD: boot_ustar.S,v 1.11 2020/01/18 05:07:34 isaki Exp $
 
 | supports floppy only
 
@@ -36,9 +36,9 @@ ASENTRY_NOPROFILE(entry0)
 		| 0xED...0xED3FFE	SRAM
 		| others		ROM (SCSI?)
 		|
-		movel	%d0,%d1
-		clrb	%d1
-		tstl	%d1
+		movel	%d0,%d6
+		clrb	%d0
+		tstl	%d0
 		jne	boot_dev_unsupported
 
 		bra	_ASM_LABEL(entry)
@@ -51,10 +51,15 @@ disklabel:
 		.space	404
 
 ASENTRY_NOPROFILE(entry)
+		| Initialize the screen first.  Some IPL (060turbo ROM or
+		| genuine boot selector) doesn't initialize the screen.
+		moveq	#0x10,%d1
+		IOCS(__CRTMOD)
+
 		|
 		| SASI or Floppy
 		|
-		movel	%d0,%d6
+		movel	%d6,%d0
 		andib	#0xFC,%d0
 		cmpib	#0x90,%d0
 		jne	boot_dev_unsupported	| boot from SASI?

Index: src/sys/arch/x68k/stand/boot_ustar/version
diff -u src/sys/arch/x68k/stand/boot_ustar/version:1.2 src/sys/arch/x68k/stand/boot_ustar/version:1.3
--- src/sys/arch/x68k/stand/boot_ustar/version:1.2	Sun Jan 12 13:51:12 2020
+++ src/sys/arch/x68k/stand/boot_ustar/version	Sat Jan 18 05:07:34 2020
@@ -1,7 +1,8 @@
-$NetBSD: version,v 1.2 2020/01/12 13:51:12 isaki Exp $
+$NetBSD: version,v 1.3 2020/01/18 05:07:34 isaki Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entr

CVS commit: src/sys/arch/x68k/stand

2020-01-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 18 04:42:29 UTC 2020

Added Files:
src/sys/arch/x68k/stand: README

Log Message:
Add a document about this directory.
Reviewed by tsutsui@ on port-x68k.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/x68k/stand/README

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

Added files:

Index: src/sys/arch/x68k/stand/README
diff -u /dev/null src/sys/arch/x68k/stand/README:1.1
--- /dev/null	Sat Jan 18 04:42:29 2020
+++ src/sys/arch/x68k/stand/README	Sat Jan 18 04:42:29 2020
@@ -0,0 +1,57 @@
+$NetBSD: README,v 1.1 2020/01/18 04:42:29 isaki Exp $
+
+Primary bootloaders:
+	boot_ufs/
+		contains xxboot_ufs.
+		It is placed in ffs's boot area and loads secondary bootloader
+		from its filesystem (ffsv1/v2).
+		This historical primary bootloader uses custom ffs op functions
+		and can recognize Human68k partition table.
+		(See #ifdef SCSI_ADHOC_BOOTPART part for details)
+
+	boot_ustar/
+		is placed in floppy's sector#0 and loads secondary bootloader
+		from subsequent USTARFS.
+
+	xxboot/
+		contains following variants.
+		* cdboot_cd9660
+			is placed in CD and loads secondary bootloader
+			from cd9660 filesystem.
+		* xxboot_ffsv1
+		* xxboot_ffsv2
+		* xxboot_lfsv1
+		* xxboot_lfsv2
+			is placed in each specified filesystem's boot area,
+			and loads secondary bootloader from its filesystem.
+
+		These primary bootloaders use MI ffs/lfs op functions in
+		src/sys/lib/libsa. Currently these don't recognize Human68k
+		partition table.
+
+Secondary bootloaders:
+	boot/
+		boot is placed to / (root directory) and loads the kernel.
+
+	netboot/
+		netboot is the same as /boot except default boot device is
+		nfs using network interface and DHCP.
+		Currently only NE2000 based Neptune-X and Nereid are
+		supported.
+
+Other bootloaders:
+	mboot/
+		mboot is 0-th bootloader.
+		It is placed to sector#0 (as 1024byte/sector) of hard disk
+		as an alternative to genuine boot selector.  And loads
+		active partition's +0 sector (sector size depends media)
+		which should have primary bootloader.
+
+	loadbsd/
+		loadbsd.x is a Human68k executable and loads the kernel from
+		Human68k filesystem.
+
+Utility tools:
+	newdisk/
+		newdisk is a utility to create the "disk mark" for X680x0
+		SCSI IPL using mboot bootloader to make a disk bootable.



CVS commit: src/sys/arch/x68k/stand

2020-01-16 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 16 13:37:27 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S
src/sys/arch/x68k/stand/boot_ustar: boot_ustar.S
src/sys/arch/x68k/stand/xxboot: boot.S

Log Message:
Use .org directive to fix disklabel location instead of hand calculation.
If the code size before disklabel is less, zero is filled automatically.
If the code size before disklabel is exceeded, assembler stops with error.
Note that this changes a padding word in the current output binary from
a NOP instruction to zero but there are no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x68k/stand/xxboot/boot.S

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/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.12 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.13
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.12	Tue Jan 14 04:00:41 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Thu Jan 16 13:37:26 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.12 2020/01/14 04:00:41 isaki Exp $
+| $NetBSD: boot.S,v 1.13 2020/01/16 13:37:26 isaki Exp $
 
 #include 
 #include "iocscall.h"
@@ -44,7 +44,7 @@ ASENTRY_NOPROFILE(entry0)
 |	Disklabel= 404bytes
 |	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x000f01d4)
-		nop
+		.org	0x40
 disklabel:
 		.space	404
 

Index: src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.9 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.10
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.9	Mon Jan 13 03:34:05 2020
+++ src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S	Thu Jan 16 13:37:26 2020
@@ -3,7 +3,7 @@
 | ITOH Yasufumi
 |	  mino...@netbsd.org
 |
-| $NetBSD: boot_ustar.S,v 1.9 2020/01/13 03:34:05 isaki Exp $
+| $NetBSD: boot_ustar.S,v 1.10 2020/01/16 13:37:26 isaki Exp $
 
 | supports floppy only
 
@@ -46,8 +46,8 @@ ASENTRY_NOPROFILE(entry0)
 |	Disklabel= 404bytes
 |	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x21d4)
-		nop
-GLOBAL(disklabel)
+		.org	0x40
+disklabel:
 		.space	404
 
 ASENTRY_NOPROFILE(entry)

Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u src/sys/arch/x68k/stand/xxboot/boot.S:1.4 src/sys/arch/x68k/stand/xxboot/boot.S:1.5
--- src/sys/arch/x68k/stand/xxboot/boot.S:1.4	Mon Jan 13 03:34:05 2020
+++ src/sys/arch/x68k/stand/xxboot/boot.S	Thu Jan 16 13:37:27 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.4 2020/01/13 03:34:05 isaki Exp $
+| $NetBSD: boot.S,v 1.5 2020/01/16 13:37:27 isaki Exp $
 
 #include 
 #include "iocscall.h"
@@ -46,7 +46,7 @@ ASENTRY_NOPROFILE(entry0)
 |	Disklabel= 404bytes
 |	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x000f01d4)
-		nop
+		.org	0x40
 disklabel:
 		.space	404
 



CVS commit: src/sys/arch/x68k/stand

2020-01-16 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 16 13:15:47 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: Makefile
src/sys/arch/x68k/stand/boot_ustar: Makefile
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot

Log Message:
Rewrite limit check using cross-build tools.
This eliminates use of hosts tr(1) and bc(1).
(But I'm going to remove this again soon due to other reason)


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot

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/x68k/stand/boot_ufs/Makefile
diff -u src/sys/arch/x68k/stand/boot_ufs/Makefile:1.30 src/sys/arch/x68k/stand/boot_ufs/Makefile:1.31
--- src/sys/arch/x68k/stand/boot_ufs/Makefile:1.30	Sat Apr  8 19:53:23 2017
+++ src/sys/arch/x68k/stand/boot_ufs/Makefile	Thu Jan 16 13:15:47 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.30 2017/04/08 19:53:23 christos Exp $
+#	$NetBSD: Makefile,v 1.31 2020/01/16 13:15:47 isaki Exp $
 
 NOMAN=		# defined
 
@@ -59,13 +59,11 @@ $(PROG): $(OBJS)
 	:
 	$(LD) $(LINKFLAGS) -o $(PROG).x $(OBJS) $(LDADD) >$(PROG).map
 	@grep first_kbyte $(PROG).map
-	@if [ `(echo ibase=16;		\
-		${TOOL_SED} -n	-e '/[ 	]first_kbyte/{'			\
-			-e 's/.*0x\([0-9a-fA-F]*\).*/\1-$(TEXT)-400/p'	\
-			-e '}' $(PROG).map |\
-		tr a-f A-F) | bc` -gt 0 ];\
-	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	\
-		exit 1;			\
+	@if [ `${TOOL_AWK}		   \
+	'/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
+	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
+	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
+	exit 1;			   \
 	fi
 	mv -f $(PROG).x $(PROG)
 

Index: src/sys/arch/x68k/stand/boot_ustar/Makefile
diff -u src/sys/arch/x68k/stand/boot_ustar/Makefile:1.24 src/sys/arch/x68k/stand/boot_ustar/Makefile:1.25
--- src/sys/arch/x68k/stand/boot_ustar/Makefile:1.24	Sat Apr  8 19:53:23 2017
+++ src/sys/arch/x68k/stand/boot_ustar/Makefile	Thu Jan 16 13:15:47 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.24 2017/04/08 19:53:23 christos Exp $
+#	$NetBSD: Makefile,v 1.25 2020/01/16 13:15:47 isaki Exp $
 
 NOMAN=		# defined
 
@@ -50,19 +50,15 @@ ${PROG}: $(OBJS)
 	${_MKTARGET_LINK}
 	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDADD) > $(PROG).map
 	@grep first_kbyte $(PROG).map
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'\
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
+	@if [ `${TOOL_AWK}		   \
+	'/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
+	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
 	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
 	rm $(PROG) ; exit 1; 	   \
 	fi
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/^.*0x\([0-9a-f]*\).* _edata *= *\.$$/\1-$(TEXT)-2000/p' \
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
+	@if [ `${TOOL_AWK}		   \
+	'/_edata/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'	   \
+	$(PROG).map | ${TOOL_M4} -` -gt 8192 ];			   \
 	then echo '$(BOOT): text+data is too large';			   \
 	rm $(PROG) ; exit 1; 	   \
 	fi

Index: src/sys/arch/x68k/stand/xxboot/Makefile.xxboot
diff -u src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.5 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.6
--- src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.5	Thu Jan 16 12:54:16 2020
+++ src/sys/arch/x68k/stand/xxboot/Makefile.xxboot	Thu Jan 16 13:15:47 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.xxboot,v 1.5 2020/01/16 12:54:16 isaki Exp $
+#	$NetBSD: Makefile.xxboot,v 1.6 2020/01/16 13:15:47 isaki Exp $
 
 NOMAN=		# defined
 
@@ -64,19 +64,17 @@ ${PROG}: $(OBJS)
 	${_MKTARGET_LINK}
 	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
 	@grep first_kbyte $(PROG).map
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'\
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
+	@if [ `${TOOL_AWK}		   \
+	'/first_kbyte/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'  \
+	$(PROG).map | ${TOOL_M4} -` -gt 1024 ];			   \
 	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
 	rm $(PROG) ; exit 1; 	   \
 	fi
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/^.*0x\([0-9a-f]*\).* _edata *= *\.$$/\1-$(TEXT)-$(TEXTDATASIZE)/p' \
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
+	@if [ `${TOOL_AWK}		   \
+	'/_edata/ {print "eval(eval("$$1")-eval(0x'$(TEXT)'))"}'	   \
+	$(PROG).map | ${TOOL_M4} -`	   \
+	-gt   

CVS commit: src/sys/arch/x68k/stand/xxboot

2020-01-16 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 16 12:54:16 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/xxboot: Makefile.xxboot

Log Message:
Remove .else part of .if OBJECT_FMT == ELF.
All similar parts in other Makefiles are removed in 2010.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot

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/x68k/stand/xxboot/Makefile.xxboot
diff -u src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.4 src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.5
--- src/sys/arch/x68k/stand/xxboot/Makefile.xxboot:1.4	Sat Apr  8 19:53:23 2017
+++ src/sys/arch/x68k/stand/xxboot/Makefile.xxboot	Thu Jan 16 12:54:16 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.xxboot,v 1.4 2017/04/08 19:53:23 christos Exp $
+#	$NetBSD: Makefile.xxboot,v 1.5 2020/01/16 12:54:16 isaki Exp $
 
 NOMAN=		# defined
 
@@ -38,12 +38,8 @@ CPPFLAGS+= -DBOOT_STAGE1 $(BOOTCPPFLAGS)
 CPPFLAGS+= -nostdinc -I${.OBJDIR} -I${S}
 CPPFLAGS+= -I$M/stand/libiocs -I$M/stand/libsa -I$M/stand/common
 AFLAGS=	   ${CFLAGS:M-[ID]*}
-.if ${OBJECT_FMT} == "ELF"
 LINKFLAGS=   -n -Bstatic -T ${.CURDIR}/../xxboot.ldscript -M
 LINKFLAGS+=  -noinhibit-exec	# XXX
-.else
-LINKFLAGS=   -n -Bstatic -Ttext ${TEXT} -M
-.endif
 LIBIOCS!= cd $M/stand/libiocs && ${PRINTOBJDIR}
 LIBSA!=	  cd $M/stand/libsa && ${PRINTOBJDIR}
 LDLIBS=	  -L${LIBSA}/lib/sa -lsa -L ${LIBSA}/lib/kern -lkern
@@ -68,7 +64,6 @@ ${PROG}: $(OBJS)
 	${_MKTARGET_LINK}
 	$(LD) $(LINKFLAGS) -o ${PROG} $(OBJS) $(LDLIBS) > $(PROG).map
 	@grep first_kbyte $(PROG).map
-.if ${OBJECT_FMT} == "ELF"
 	@if [ `(echo ibase=16; 		   \
 	${TOOL_SED} -n		   \
 		's/^.*0x\([0-9a-f]*\).* first_kbyte$$/\1-$(TEXT)-400/p'\
@@ -85,27 +80,6 @@ ${PROG}: $(OBJS)
 	then echo '$(BOOT): text+data is too large';			   \
 	rm $(PROG) ; exit 1; 	   \
 	fi
-.else
-	mv $(PROG) $(PROG).x
-	$(OBJCOPY) -I a.out-m68k-netbsd -O binary $(PROG).x $(PROG)
-	@rm -f $(PROG).x
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/  first_kbyte:.*0x\(.*\),.*$$/\1-$(TEXT)-400/p'	   \
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
-	then echo '$(BOOT): first_kbyte exceeds the first killobyte';	   \
-	rm $(PROG) ; exit 1; 	   \
-	fi
-	@if [ `(echo ibase=16; 		   \
-	${TOOL_SED} -n		   \
-		's/  _edata:.*0x\(.*\),.*$$/\1-$(TEXT)-$(TEXTDATASIZE)/p'  \
-		$(PROG).map | 		   \
-	tr a-f A-F) | bc` -gt 0 ]; 	   \
-	then echo '$(BOOT): text+data is too large';			   \
-	rm $(PROG) ; exit 1; 	   \
-	fi
-.endif
 	${TOUCHPROG}
 
 .include 



CVS commit: src/sys/arch/x68k/stand/boot_ufs

2020-01-13 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Jan 14 04:00:41 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S boot_ufs.h

Log Message:
Clean up.
- B_KEYINP is no longer called from C.
- B_COLOR is no longer used.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.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/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.11 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.12
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.11	Mon Jan 13 03:34:05 2020
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Tue Jan 14 04:00:41 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.11 2020/01/13 03:34:05 isaki Exp $
+| $NetBSD: boot.S,v 1.12 2020/01/14 04:00:41 isaki Exp $
 
 #include 
 #include "iocscall.h"
@@ -451,10 +451,6 @@ raw_read_end:
 read_half:	BOOT_ERROR("read half of block")
 
 
-ENTRY_NOPROFILE(B_KEYINP)
-		IOCS(__B_KEYINP)
-		rts
-
 ENTRY_NOPROFILE(B_PUTC)
 		movel	%sp@(4),%d1
 		IOCS(__B_PUTC)

Index: src/sys/arch/x68k/stand/boot_ufs/boot_ufs.h
diff -u src/sys/arch/x68k/stand/boot_ufs/boot_ufs.h:1.5 src/sys/arch/x68k/stand/boot_ufs/boot_ufs.h:1.6
--- src/sys/arch/x68k/stand/boot_ufs/boot_ufs.h:1.5	Sat Mar 14 14:46:07 2009
+++ src/sys/arch/x68k/stand/boot_ufs/boot_ufs.h	Tue Jan 14 04:00:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot_ufs.h,v 1.5 2009/03/14 14:46:07 dsl Exp $	*/
+/*	$NetBSD: boot_ufs.h,v 1.6 2020/01/14 04:00:41 isaki Exp $	*/
 
 /***
  *
@@ -14,10 +14,8 @@ int badbaddr(volatile void *adr);
 #ifdef SCSI_ADHOC_BOOTPART
 void RAW_READ0(void *buf, u_int32_t blkpos, size_t bytelen);
 #endif
-unsigned B_KEYINP(void);
 void B_PUTC(unsigned int c);
 void B_PRINT(const char *p);
-unsigned B_COLOR(unsigned int w);
 
 extern unsigned ID;		/* target SCSI ID */
 extern unsigned BOOT_INFO;	/* result of IOCS(__BOOTINF) */



CVS commit: src/sys/arch/x68k/stand/boot

2020-01-13 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Jan 14 03:48:10 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot: boot.c

Log Message:
consio_init() should be done before printf().


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/x68k/stand/boot/boot.c

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/x68k/stand/boot/boot.c
diff -u src/sys/arch/x68k/stand/boot/boot.c:1.30 src/sys/arch/x68k/stand/boot/boot.c:1.31
--- src/sys/arch/x68k/stand/boot/boot.c:1.30	Thu Aug  4 12:15:07 2016
+++ src/sys/arch/x68k/stand/boot/boot.c	Tue Jan 14 03:48:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.30 2016/08/04 12:15:07 isaki Exp $	*/
+/*	$NetBSD: boot.c,v 1.31 2020/01/14 03:48:10 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Minoura Makoto
@@ -387,6 +387,8 @@ bootmain(int bootdev)
 	u_int sram_memsize;
 	u_int probed_memsize;
 
+	console_device = consio_init(console_device);
+
 	hostadaptor = get_scsi_host_adapter();
 	rtc_offset = RTC_OFFSET;
 	try_bootp = 1;
@@ -402,7 +404,6 @@ bootmain(int bootdev)
 		exit(1);
 	}
 
-	console_device = consio_init(console_device);
 	setheap(HEAP_START, HEAP_END);
 
 #if !defined(NETBOOT)



CVS commit: src/sys/arch/x68k/stand

2020-01-12 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Mon Jan 13 03:34:05 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: boot.S
src/sys/arch/x68k/stand/boot_ustar: boot_ustar.S
src/sys/arch/x68k/stand/xxboot: boot.S

Log Message:
Typo in comment.  s/LABELLOFFSET/LABELOFFSET/


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x68k/stand/boot_ufs/boot.S
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x68k/stand/xxboot/boot.S

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/x68k/stand/boot_ufs/boot.S
diff -u src/sys/arch/x68k/stand/boot_ufs/boot.S:1.10 src/sys/arch/x68k/stand/boot_ufs/boot.S:1.11
--- src/sys/arch/x68k/stand/boot_ufs/boot.S:1.10	Thu Nov  1 14:33:31 2012
+++ src/sys/arch/x68k/stand/boot_ufs/boot.S	Mon Jan 13 03:34:05 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.10 2012/11/01 14:33:31 isaki Exp $
+| $NetBSD: boot.S,v 1.11 2020/01/13 03:34:05 isaki Exp $
 
 #include 
 #include "iocscall.h"
@@ -42,7 +42,7 @@ ASENTRY_NOPROFILE(entry0)
 		bra	_ASM_LABEL(entry)
 
 |	Disklabel= 404bytes
-|	Since LABELLOFFSET in  is 0x40,
+|	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x000f01d4)
 		nop
 disklabel:

Index: src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S
diff -u src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.8 src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.9
--- src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S:1.8	Sat Jun 25 04:08:57 2016
+++ src/sys/arch/x68k/stand/boot_ustar/boot_ustar.S	Mon Jan 13 03:34:05 2020
@@ -3,7 +3,7 @@
 | ITOH Yasufumi
 |	  mino...@netbsd.org
 |
-| $NetBSD: boot_ustar.S,v 1.8 2016/06/25 04:08:57 isaki Exp $
+| $NetBSD: boot_ustar.S,v 1.9 2020/01/13 03:34:05 isaki Exp $
 
 | supports floppy only
 
@@ -44,7 +44,7 @@ ASENTRY_NOPROFILE(entry0)
 		bra	_ASM_LABEL(entry)
 
 |	Disklabel= 404bytes
-|	Since LABELLOFFSET in  is 0x40,
+|	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x21d4)
 		nop
 GLOBAL(disklabel)

Index: src/sys/arch/x68k/stand/xxboot/boot.S
diff -u src/sys/arch/x68k/stand/xxboot/boot.S:1.3 src/sys/arch/x68k/stand/xxboot/boot.S:1.4
--- src/sys/arch/x68k/stand/xxboot/boot.S:1.3	Sat Nov 17 15:53:21 2012
+++ src/sys/arch/x68k/stand/xxboot/boot.S	Mon Jan 13 03:34:05 2020
@@ -2,7 +2,7 @@
 | author: chapuni(webmas...@chapuni.com)
 | ITOH Yasufumi
 |
-| $NetBSD: boot.S,v 1.3 2012/11/17 15:53:21 tsutsui Exp $
+| $NetBSD: boot.S,v 1.4 2020/01/13 03:34:05 isaki Exp $
 
 #include 
 #include "iocscall.h"
@@ -44,7 +44,7 @@ ASENTRY_NOPROFILE(entry0)
 		bra	_ASM_LABEL(entry)
 
 |	Disklabel= 404bytes
-|	Since LABELLOFFSET in  is 0x40,
+|	Since LABELOFFSET in  is 0x40,
 |	entry must be after 0x01d4 (0x000f01d4)
 		nop
 disklabel:



CVS commit: src/sys/arch/x68k/stand

2020-01-12 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Jan 12 13:51:12 UTC 2020

Modified Files:
src/sys/arch/x68k/stand/boot_ufs: version
src/sys/arch/x68k/stand/boot_ustar: version

Log Message:
Fix broken RCS NetBSD tag.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x68k/stand/boot_ufs/version
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x68k/stand/boot_ustar/version

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/x68k/stand/boot_ufs/version
diff -u src/sys/arch/x68k/stand/boot_ufs/version:1.2 src/sys/arch/x68k/stand/boot_ufs/version:1.3
--- src/sys/arch/x68k/stand/boot_ufs/version:1.2	Sun Mar 17 16:14:31 2002
+++ src/sys/arch/x68k/stand/boot_ufs/version	Sun Jan 12 13:51:12 2020
@@ -1,4 +1,4 @@
-$ NetBSD $
+$NetBSD: version,v 1.3 2020/01/12 13:51:12 isaki Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item

Index: src/sys/arch/x68k/stand/boot_ustar/version
diff -u src/sys/arch/x68k/stand/boot_ustar/version:1.1 src/sys/arch/x68k/stand/boot_ustar/version:1.2
--- src/sys/arch/x68k/stand/boot_ustar/version:1.1	Mon Oct 15 16:23:01 2001
+++ src/sys/arch/x68k/stand/boot_ustar/version	Sun Jan 12 13:51:12 2020
@@ -1,4 +1,4 @@
-$ NetBSD $
+$NetBSD: version,v 1.2 2020/01/12 13:51:12 isaki Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item



CVS commit: src/sys/dev/audio

2020-01-10 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 11 04:53:10 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c audiovar.h

Log Message:
Simplify async_mixer handling.
- It makes FIOASYNC code in mixer_ioctl() symmetric.
- For readability, mixer_async_{add,remove}() should take pid argument
  though pid is always curproc.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/audio/audiovar.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/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.40 src/sys/dev/audio/audio.c:1.41
--- src/sys/dev/audio/audio.c:1.40	Sat Jan 11 04:06:13 2020
+++ src/sys/dev/audio/audio.c	Sat Jan 11 04:53:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.40 2020/01/11 04:06:13 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.41 2020/01/11 04:53:10 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.40 2020/01/11 04:06:13 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.41 2020/01/11 04:53:10 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -463,6 +463,9 @@ audio_track_bufstat(audio_track_t *track
 int audio_idle_timeout = 30;
 #endif
 
+/* Number of elements of async mixer's pid */
+#define AM_CAPACITY	(4)
+
 struct portname {
 	const char *name;
 	int mask;
@@ -604,7 +607,8 @@ static void mixer_init(struct audio_soft
 static int mixer_open(dev_t, struct audio_softc *, int, int, struct lwp *);
 static int mixer_close(struct audio_softc *, audio_file_t *);
 static int mixer_ioctl(struct audio_softc *, u_long, void *, int, struct lwp *);
-static void mixer_remove(struct audio_softc *);
+static void mixer_async_add(struct audio_softc *, pid_t);
+static void mixer_async_remove(struct audio_softc *, pid_t);
 static void mixer_signal(struct audio_softc *);
 
 static int au_portof(struct audio_softc *, char *, int);
@@ -878,6 +882,9 @@ audioattach(device_t parent, device_t se
 	sc->sc_blk_ms = AUDIO_BLK_MS;
 	SLIST_INIT(&sc->sc_files);
 	cv_init(&sc->sc_exlockcv, "audiolk");
+	sc->sc_am_capacity = 0;
+	sc->sc_am_used = 0;
+	sc->sc_am = NULL;
 
 	mutex_enter(sc->sc_lock);
 	sc->sc_props = hw_if->get_props(sc->hw_hdl);
@@ -1283,6 +1290,8 @@ audiodetach(device_t self, int flags)
 		kmem_free(sc->sc_rmixer, sizeof(*sc->sc_rmixer));
 	}
 	mutex_exit(sc->sc_lock);
+	if (sc->sc_am)
+		kern_free(sc->sc_am);
 
 	seldestroy(&sc->sc_wsel);
 	seldestroy(&sc->sc_rsel);
@@ -7604,23 +7613,60 @@ mixer_open(dev_t dev, struct audio_softc
 }
 
 /*
+ * Add a process to those to be signalled on mixer activity.
+ * If the process has already been added, do nothing.
+ * Must be called with sc_lock held.
+ */
+static void
+mixer_async_add(struct audio_softc *sc, pid_t pid)
+{
+	int i;
+
+	KASSERT(mutex_owned(sc->sc_lock));
+
+	/* If already exists, returns without doing anything. */
+	for (i = 0; i < sc->sc_am_used; i++) {
+		if (sc->sc_am[i] == pid)
+			return;
+	}
+
+	/* Extend array if necessary. */
+	if (sc->sc_am_used >= sc->sc_am_capacity) {
+		sc->sc_am_capacity += AM_CAPACITY;
+		sc->sc_am = kern_realloc(sc->sc_am,
+		sc->sc_am_capacity * sizeof(pid_t), M_WAITOK);
+		TRACE(2, "realloc am_capacity=%d", sc->sc_am_capacity);
+	}
+
+	TRACE(2, "am[%d]=%d", sc->sc_am_used, (int)pid);
+	sc->sc_am[sc->sc_am_used++] = pid;
+}
+
+/*
  * Remove a process from those to be signalled on mixer activity.
+ * If the process has not been added, do nothing.
  * Must be called with sc_lock held.
  */
 static void
-mixer_remove(struct audio_softc *sc)
+mixer_async_remove(struct audio_softc *sc, pid_t pid)
 {
-	struct mixer_asyncs **pm, *m;
-	pid_t pid;
+	int i;
 
 	KASSERT(mutex_owned(sc->sc_lock));
 
-	pid = curproc->p_pid;
-	for (pm = &sc->sc_async_mixer; *pm; pm = &(*pm)->next) {
-		if ((*pm)->pid == pid) {
-			m = *pm;
-			*pm = m->next;
-			kmem_free(m, sizeof(*m));
+	for (i = 0; i < sc->sc_am_used; i++) {
+		if (sc->sc_am[i] == pid) {
+			sc->sc_am[i] = sc->sc_am[--sc->sc_am_used];
+			TRACE(2, "am[%d](%d) removed, used=%d",
+			i, (int)pid, sc->sc_am_used);
+
+			/* Empty array if no longer necessary. */
+			if (sc->sc_am_used == 0) {
+kern_free(sc->sc_am);
+sc->sc_am = NULL;
+sc->sc_am_capacity = 0;
+TRACE(2, "released");
+			}
 			return;
 		}
 	}
@@ -7633,12 +7679,15 @@ mixer_remove(struct audio_softc *sc)
 static void
 mixer_signal(struct audio_softc *sc)
 {
-	struct mixer_asyncs *m;
 	proc_t *p;
+	int i;
+
+	KASSERT(mutex_owned(sc->sc_lock));
 
-	for (m = sc->sc_async_mixer; m; m = m->next) {
+	for (i = 0; i < sc->sc_am_used; i++) {
 		mutex_enter(proc_lock);
-		if ((p = proc_find(m->pid)) != NULL)
+		p = proc_find(sc->sc_am[i]);
+		if (p)
 			psignal(p, SIGIO);
 		mutex_exit(proc_lock);
 	}
@@ -7653,7 +7702,7 @@ mixer_close(struct audio_softc *sc, audi
 
 	mutex_enter(sc->sc_lock);
 	TRACE

CVS commit: src/sys/dev/audio

2020-01-10 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan 11 04:06:13 UTC 2020

Modified Files:
src/sys/dev/audio: alaw.c audio.c audiovar.h linear.c mulaw.c

Log Message:
Remove old debug #ifdefs.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/audio/alaw.c src/sys/dev/audio/linear.c \
src/sys/dev/audio/mulaw.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/audio/audiovar.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/dev/audio/alaw.c
diff -u src/sys/dev/audio/alaw.c:1.2 src/sys/dev/audio/alaw.c:1.3
--- src/sys/dev/audio/alaw.c:1.2	Wed May  8 13:40:17 2019
+++ src/sys/dev/audio/alaw.c	Sat Jan 11 04:06:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: alaw.c,v 1.2 2019/05/08 13:40:17 isaki Exp $	*/
+/*	$NetBSD: alaw.c,v 1.3 2020/01/11 04:06:13 isaki Exp $	*/
 
 /*
  * Copyright (C) 2018 Tetsuya Isaki. All rights reserved.
@@ -26,15 +26,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: alaw.c,v 1.2 2019/05/08 13:40:17 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: alaw.c,v 1.3 2020/01/11 04:06:13 isaki Exp $");
 
-#if defined(_KERNEL)
 #include 
 #include 
 #include 
 #include 
 #include 
-#endif
 
 static const uint16_t alaw_to_slinear16[256] = {
 	0xea80, 0xeb80, 0xe880, 0xe980, 0xee80, 0xef80, 0xec80, 0xed80,
Index: src/sys/dev/audio/linear.c
diff -u src/sys/dev/audio/linear.c:1.2 src/sys/dev/audio/linear.c:1.3
--- src/sys/dev/audio/linear.c:1.2	Wed May  8 13:40:17 2019
+++ src/sys/dev/audio/linear.c	Sat Jan 11 04:06:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: linear.c,v 1.2 2019/05/08 13:40:17 isaki Exp $	*/
+/*	$NetBSD: linear.c,v 1.3 2020/01/11 04:06:13 isaki Exp $	*/
 
 /*
  * Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -26,21 +26,14 @@
  * SUCH DAMAGE.
  */
 
-#if defined(_KERNEL)
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linear.c,v 1.2 2019/05/08 13:40:17 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linear.c,v 1.3 2020/01/11 04:06:13 isaki Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
-#else
-#include 
-#include 
-#include "compat.h"
-#include "audiovar.h"
-#endif /* _KERNEL */
 
 /*
  * audio_linear8_to_internal:
Index: src/sys/dev/audio/mulaw.c
diff -u src/sys/dev/audio/mulaw.c:1.2 src/sys/dev/audio/mulaw.c:1.3
--- src/sys/dev/audio/mulaw.c:1.2	Wed May  8 13:40:17 2019
+++ src/sys/dev/audio/mulaw.c	Sat Jan 11 04:06:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mulaw.c,v 1.2 2019/05/08 13:40:17 isaki Exp $	*/
+/*	$NetBSD: mulaw.c,v 1.3 2020/01/11 04:06:13 isaki Exp $	*/
 
 /*
  * Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -26,21 +26,14 @@
  * SUCH DAMAGE.
  */
 
-#if defined(_KERNEL)
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mulaw.c,v 1.2 2019/05/08 13:40:17 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mulaw.c,v 1.3 2020/01/11 04:06:13 isaki Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
-#else
-#include 
-#include 
-#include "compat.h"
-#include "audiovar.h"
-#endif /* _KERNEL */
 
 /*
  * audio_internal_to_mulaw has two implementations.

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.39 src/sys/dev/audio/audio.c:1.40
--- src/sys/dev/audio/audio.c:1.39	Wed Jan  8 13:30:15 2020
+++ src/sys/dev/audio/audio.c	Sat Jan 11 04:06:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.39 2020/01/08 13:30:15 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.40 2020/01/11 04:06:13 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.39 2020/01/08 13:30:15 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.40 2020/01/11 04:06:13 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -151,8 +151,6 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.
 
 #if NAUDIO > 0
 
-#ifdef _KERNEL
-
 #include 
 #include 
 #include 
@@ -193,7 +191,6 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.
 #include 
 
 #include "ioconf.h"
-#endif /* _KERNEL */
 
 /*
  * 0: No debug logs
@@ -5220,11 +5217,6 @@ audio_pintr(void *arg)
 	mixer->hwseq, mixer->hw_complete_counter,
 	mixer->hwbuf.head, mixer->hwbuf.used, mixer->hwbuf.capacity);
 
-#if !defined(_KERNEL)
-	/* This is a debug code for userland test. */
-	return;
-#endif
-
 #if defined(AUDIO_HW_SINGLE_BUFFER)
 	/*
 	 * Create a new block here and output it immediately.

Index: src/sys/dev/audio/audiovar.h
diff -u src/sys/dev/audio/audiovar.h:1.5 src/sys/dev/audio/audiovar.h:1.6
--- src/sys/dev/audio/audiovar.h:1.5	Thu Aug 29 13:01:07 2019
+++ src/sys/dev/audio/audiovar.h	Sat Jan 11 04:06:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiovar.h,v 1.5 2019/08/29 13:01:07 isaki Exp $	*/
+/*	$NetBSD: audiovar.h,v 1.6 2020/01/11 04:06:13 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2002 The Net

CVS commit: src/sys/dev/audio

2020-01-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed Jan  8 13:30:16 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Fix an resource leak on audiobell close.
audioclose() freed audio_file_t structure, but only audiobellclose
didn't pass there.  I change that all of freeing audio_file_t is done
by each *_close().


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.38 src/sys/dev/audio/audio.c:1.39
--- src/sys/dev/audio/audio.c:1.38	Wed Jan  8 13:05:02 2020
+++ src/sys/dev/audio/audio.c	Wed Jan  8 13:30:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.38 2020/01/08 13:05:02 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.39 2020/01/08 13:30:15 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.38 2020/01/08 13:05:02 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.39 2020/01/08 13:30:15 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -530,6 +530,7 @@ static int audio_mmap(struct audio_softc
 	struct uvm_object **, int *, audio_file_t *);
 
 static int audioctl_open(dev_t, struct audio_softc *, int, int, struct lwp *);
+static int audioctl_close(struct audio_softc *, audio_file_t *);
 
 static void audio_pintr(void *);
 static void audio_rintr(void *);
@@ -1521,7 +1522,7 @@ audioclose(struct file *fp)
 		error = audio_close(sc, file);
 		break;
 	case AUDIOCTL_DEVICE:
-		error = 0;
+		error = audioctl_close(sc, file);
 		break;
 	case MIXER_DEVICE:
 		error = mixer_close(sc, file);
@@ -1530,10 +1531,8 @@ audioclose(struct file *fp)
 		error = ENXIO;
 		break;
 	}
-	if (error == 0) {
-		kmem_free(fp->f_audioctx, sizeof(audio_file_t));
-		fp->f_audioctx = NULL;
-	}
+	/* f_audioctx has already been freed in lower *_close() */
+	fp->f_audioctx = NULL;
 
 	return error;
 }
@@ -2196,6 +2195,8 @@ audio_close(struct audio_softc *sc, audi
 
 	TRACE(3, "done");
 	audio_exit_exclusive(sc);
+
+	kmem_free(file, sizeof(*file));
 	return 0;
 }
 
@@ -3055,6 +3056,14 @@ audioctl_open(dev_t dev, struct audio_so
 	return error;
 }
 
+static int
+audioctl_close(struct audio_softc *sc, audio_file_t *file)
+{
+
+	kmem_free(file, sizeof(*file));
+	return 0;
+}
+
 /*
  * Free 'mem' if available, and initialize the pointer.
  * For this reason, this is implemented as macro.
@@ -7655,6 +7664,7 @@ mixer_close(struct audio_softc *sc, audi
 	mixer_remove(sc);
 	mutex_exit(sc->sc_lock);
 
+	kmem_free(file, sizeof(*file));
 	return 0;
 }
 



CVS commit: src/sys/dev/audio

2020-01-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed Jan  8 13:05:02 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Remove obsoleted comment.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.37 src/sys/dev/audio/audio.c:1.38
--- src/sys/dev/audio/audio.c:1.37	Wed Jan  8 08:10:15 2020
+++ src/sys/dev/audio/audio.c	Wed Jan  8 13:05:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.37 2020/01/08 08:10:15 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.38 2020/01/08 13:05:02 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.37 2020/01/08 08:10:15 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.38 2020/01/08 13:05:02 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1798,11 +1798,6 @@ audiobellclose(audio_file_t *file)
 	device_active(sc->sc_dev, DVA_SYSTEM);
 	error = audio_close(sc, file);
 
-	/*
-	 * Since file has already been destructed,
-	 * audio_file_release() is not necessary.
-	 */
-
 	return error;
 }
 



CVS commit: src/sys/dev/audio

2020-01-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed Jan  8 08:10:15 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Move mutex_exit() correct place to protect sc_async_mixer.
Thanks maxv@!


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.36 src/sys/dev/audio/audio.c:1.37
--- src/sys/dev/audio/audio.c:1.36	Fri Dec 27 09:45:26 2019
+++ src/sys/dev/audio/audio.c	Wed Jan  8 08:10:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.36 2019/12/27 09:45:26 msaitoh Exp $	*/
+/*	$NetBSD: audio.c,v 1.37 2020/01/08 08:10:15 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.36 2019/12/27 09:45:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.37 2020/01/08 08:10:15 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -7694,12 +7694,12 @@ mixer_ioctl(struct audio_softc *sc, u_lo
 		}
 		mutex_enter(sc->sc_lock);
 		mixer_remove(sc);	/* remove old entry */
-		mutex_exit(sc->sc_lock);
 		if (ma != NULL) {
 			ma->next = sc->sc_async_mixer;
 			ma->pid = curproc->p_pid;
 			sc->sc_async_mixer = ma;
 		}
+		mutex_exit(sc->sc_lock);
 		error = 0;
 		break;
 



CVS commit: src/sys/arch/luna68k/include

2019-12-28 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Dec 28 12:34:35 UTC 2019

Modified Files:
src/sys/arch/luna68k/include: param.h

Log Message:
Remove a pointless MSGBUFSIZE definition.
The same operation is already done in .
luna68k is not imported yet in 1997 but see also:
http://mail-index.netbsd.org/source-changes/1997/09/20/0021.html


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/luna68k/include/param.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/luna68k/include/param.h
diff -u src/sys/arch/luna68k/include/param.h:1.13 src/sys/arch/luna68k/include/param.h:1.14
--- src/sys/arch/luna68k/include/param.h:1.13	Fri Feb 10 17:35:48 2012
+++ src/sys/arch/luna68k/include/param.h	Sat Dec 28 12:34:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.13 2012/02/10 17:35:48 para Exp $ */
+/* $NetBSD: param.h,v 1.14 2019/12/28 12:34:35 isaki Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -53,10 +53,6 @@
 
 #define NPTEPG		(NBPG/(sizeof (pt_entry_t)))
 
-#ifndef MSGBUFSIZE
-#define MSGBUFSIZE	NBPG		/* default message buffer size */
-#endif
-
 /*
  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
  * logical pages.



CVS commit: src/sys/arch/x68k/include

2019-12-28 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Dec 28 11:42:18 UTC 2019

Modified Files:
src/sys/arch/x68k/include: param.h

Log Message:
Bump MSGBUFSIZE (2 * NBPG).
Since timestamp was introduced, it was too small to store full dmesg
of one boot.
And putting this behind of #include  had no effect.
This was fixed on many arch in 1997 but x68k was not...
http://mail-index.netbsd.org/source-changes/1997/09/20/0021.html


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/x68k/include/param.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/x68k/include/param.h
diff -u src/sys/arch/x68k/include/param.h:1.28 src/sys/arch/x68k/include/param.h:1.29
--- src/sys/arch/x68k/include/param.h:1.28	Fri Feb 10 17:35:47 2012
+++ src/sys/arch/x68k/include/param.h	Sat Dec 28 11:42:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.28 2012/02/10 17:35:47 para Exp $	*/
+/*	$NetBSD: param.h,v 1.29 2019/12/28 11:42:18 isaki Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -52,14 +52,14 @@
 
 #define	UPAGES		2		/* pages of u-area */
 
+#ifndef MSGBUFSIZE
+#define MSGBUFSIZE	(2 * NBPG)	/* default message buffer size */
+#endif
+
 #include 
 
 #define	NPTEPG		(NBPG/(sizeof (pt_entry_t)))
 
-#ifndef MSGBUFSIZE
-#define MSGBUFSIZE	NBPG		/* default message buffer size */
-#endif
-
 /*
  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
  * logical pages.



CVS commit: src/sys/dev/audio

2019-12-26 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Dec 26 11:27:03 UTC 2019

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Improve and simplify around audio_realloc().


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.34 src/sys/dev/audio/audio.c:1.35
--- src/sys/dev/audio/audio.c:1.34	Thu Dec 26 11:24:55 2019
+++ src/sys/dev/audio/audio.c	Thu Dec 26 11:27:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.34 2019/12/26 11:24:55 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.35 2019/12/26 11:27:03 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.34 2019/12/26 11:24:55 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.35 2019/12/26 11:27:03 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3061,30 +3061,6 @@ audioctl_open(dev_t dev, struct audio_so
 }
 
 /*
- * Reallocate 'memblock' with specified 'bytes' if 'bytes' > 0.
- * Or free 'memblock' and return NULL if 'byte' is zero.
- */
-static void *
-audio_realloc(void *memblock, size_t bytes)
-{
-
-	if (memblock != NULL) {
-		if (bytes != 0) {
-			return kern_realloc(memblock, bytes, M_WAITOK);
-		} else {
-			kern_free(memblock);
-			return NULL;
-		}
-	} else {
-		if (bytes != 0) {
-			return kern_malloc(bytes, M_WAITOK);
-		} else {
-			return NULL;
-		}
-	}
-}
-
-/*
  * Free 'mem' if available, and initialize the pointer.
  * For this reason, this is implemented as macro.
  */
@@ -3096,6 +3072,20 @@ audio_realloc(void *memblock, size_t byt
 } while (0)
 
 /*
+ * (Re)allocate 'memblock' with specified 'bytes'.
+ * bytes must not be 0.
+ * This function never returns NULL.
+ */
+static void *
+audio_realloc(void *memblock, size_t bytes)
+{
+
+	KASSERT(bytes != 0);
+	audio_free(memblock);
+	return kern_malloc(bytes, M_WAITOK);
+}
+
+/*
  * (Re)allocate usrbuf with 'newbufsize' bytes.
  * Use this function for usrbuf because only usrbuf can be mmapped.
  * If successful, it updates track->usrbuf.mem, track->usrbuf.capacity and
@@ -3660,7 +3650,6 @@ abort:
 static int
 audio_track_init_codec(audio_track_t *track, audio_ring_t **last_dstp)
 {
-	struct audio_softc *sc;
 	audio_ring_t *last_dst;
 	audio_ring_t *srcbuf;
 	audio_format2_t *srcfmt;
@@ -3671,7 +3660,6 @@ audio_track_init_codec(audio_track_t *tr
 
 	KASSERT(track);
 
-	sc = track->mixer->sc;
 	last_dst = *last_dstp;
 	dstfmt = &last_dst->fmt;
 	srcfmt = &track->inputfmt;
@@ -3700,12 +3688,6 @@ audio_track_init_codec(audio_track_t *tr
 		srcbuf->capacity = frame_per_block(track->mixer, &srcbuf->fmt);
 		len = auring_bytelen(srcbuf);
 		srcbuf->mem = audio_realloc(srcbuf->mem, len);
-		if (srcbuf->mem == NULL) {
-			device_printf(sc->sc_dev, "%s: malloc(%d) failed\n",
-			__func__, len);
-			error = ENOMEM;
-			goto abort;
-		}
 
 		arg = &track->codec.arg;
 		arg->srcfmt = &srcbuf->fmt;
@@ -3731,7 +3713,6 @@ abort:
 static int
 audio_track_init_chvol(audio_track_t *track, audio_ring_t **last_dstp)
 {
-	struct audio_softc *sc;
 	audio_ring_t *last_dst;
 	audio_ring_t *srcbuf;
 	audio_format2_t *srcfmt;
@@ -3742,7 +3723,6 @@ audio_track_init_chvol(audio_track_t *tr
 
 	KASSERT(track);
 
-	sc = track->mixer->sc;
 	last_dst = *last_dstp;
 	dstfmt = &last_dst->fmt;
 	srcfmt = &track->inputfmt;
@@ -3770,12 +3750,6 @@ audio_track_init_chvol(audio_track_t *tr
 		srcbuf->capacity = frame_per_block(track->mixer, &srcbuf->fmt);
 		len = auring_bytelen(srcbuf);
 		srcbuf->mem = audio_realloc(srcbuf->mem, len);
-		if (srcbuf->mem == NULL) {
-			device_printf(sc->sc_dev, "%s: malloc(%d) failed\n",
-			__func__, len);
-			error = ENOMEM;
-			goto abort;
-		}
 
 		arg = &track->chvol.arg;
 		arg->srcfmt = &srcbuf->fmt;
@@ -3786,7 +3760,6 @@ audio_track_init_chvol(audio_track_t *tr
 		return 0;
 	}
 
-abort:
 	track->chvol.filter = NULL;
 	audio_free(srcbuf->mem);
 	return error;
@@ -3801,7 +3774,6 @@ abort:
 static int
 audio_track_init_chmix(audio_track_t *track, audio_ring_t **last_dstp)
 {
-	struct audio_softc *sc;
 	audio_ring_t *last_dst;
 	audio_ring_t *srcbuf;
 	audio_format2_t *srcfmt;
@@ -3814,7 +3786,6 @@ audio_track_init_chmix(audio_track_t *tr
 
 	KASSERT(track);
 
-	sc = track->mixer->sc;
 	last_dst = *last_dstp;
 	dstfmt = &last_dst->fmt;
 	srcfmt = &track->inputfmt;
@@ -3845,12 +3816,6 @@ audio_track_init_chmix(audio_track_t *tr
 		srcbuf->capacity = frame_per_block(track->mixer, &srcbuf->fmt);
 		len = auring_bytelen(srcbuf);
 		srcbuf->mem = audio_realloc(srcbuf->mem, len);
-		if (srcbuf->mem == NULL) {
-			device_printf(sc->sc_dev, "%s: malloc(%d) failed\n",
-			__func__, len);
-			error = ENOMEM;
-			goto abort;
-		}
 
 		arg = &track->chmix.arg;
 		arg->srcfmt = &srcbuf->fmt;
@@ -3861,7 +3826,6 @@ audio_track_ini

CVS commit: src/sys/dev/audio

2019-12-26 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Dec 26 11:24:55 UTC 2019

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Use M_WAITOK instead of M_NOWAIT.
These allocations don't require NOWAIT constraints.
Will fix PR kern/54796.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.33 src/sys/dev/audio/audio.c:1.34
--- src/sys/dev/audio/audio.c:1.33	Wed Nov  6 13:37:27 2019
+++ src/sys/dev/audio/audio.c	Thu Dec 26 11:24:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.33 2019/11/06 13:37:27 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.34 2019/12/26 11:24:55 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.33 2019/11/06 13:37:27 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.34 2019/12/26 11:24:55 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -3070,14 +3070,14 @@ audio_realloc(void *memblock, size_t byt
 
 	if (memblock != NULL) {
 		if (bytes != 0) {
-			return kern_realloc(memblock, bytes, M_NOWAIT);
+			return kern_realloc(memblock, bytes, M_WAITOK);
 		} else {
 			kern_free(memblock);
 			return NULL;
 		}
 	} else {
 		if (bytes != 0) {
-			return kern_malloc(bytes, M_NOWAIT);
+			return kern_malloc(bytes, M_WAITOK);
 		} else {
 			return NULL;
 		}



CVS commit: src/usr.sbin/sysinst

2019-12-09 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Dec 10 06:25:50 UTC 2019

Modified Files:
src/usr.sbin/sysinst: README.md_defs

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/README.md_defs

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

Modified files:

Index: src/usr.sbin/sysinst/README.md_defs
diff -u src/usr.sbin/sysinst/README.md_defs:1.2 src/usr.sbin/sysinst/README.md_defs:1.3
--- src/usr.sbin/sysinst/README.md_defs:1.2	Mon Dec  9 19:16:53 2019
+++ src/usr.sbin/sysinst/README.md_defs	Tue Dec 10 06:25:50 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: README.md_defs,v 1.2 2019/12/09 19:16:53 martin Exp $ */
+/* $NetBSD: README.md_defs,v 1.3 2019/12/10 06:25:50 isaki Exp $ */
 
 The following is trying to document the most important machine dependent
 defines used in the sysinst code.
@@ -88,5 +88,5 @@ DISKLABEL_NO_ONDISK_VERIFY	usually undef
 
 If defined, do not verify the presence of on-disk disklabels before
 offering the disklabel partitioning scheme. This allows ports to use
-kernel translation for the disklabel ioctls (e.g. x86k uses Human68k
+kernel translation for the disklabel ioctls (e.g. x68k uses Human68k
 partitions this way).



CVS commit: src/usr.bin/audio/ctl

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 14:44:42 UTC 2019

Modified Files:
src/usr.bin/audio/ctl: audioctl.1 ctl.c

Log Message:
Remove -p option.  AUDIO_SETCHAN is insecure and is obsoleted.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/audio/ctl/audioctl.1
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/audio/ctl/ctl.c

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

Modified files:

Index: src/usr.bin/audio/ctl/audioctl.1
diff -u src/usr.bin/audio/ctl/audioctl.1:1.21 src/usr.bin/audio/ctl/audioctl.1:1.22
--- src/usr.bin/audio/ctl/audioctl.1:1.21	Fri Feb 10 19:31:42 2017
+++ src/usr.bin/audio/ctl/audioctl.1	Wed May  8 14:44:42 2019
@@ -1,4 +1,4 @@
-.\" $NetBSD: audioctl.1,v 1.21 2017/02/10 19:31:42 nat Exp $
+.\" $NetBSD: audioctl.1,v 1.22 2019/05/08 14:44:42 isaki Exp $
 .\"
 .\" Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -35,17 +35,14 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl d Ar device
-.Op Fl p Ar channel
 .Op Fl n
 .Fl a
 .Nm
 .Op Fl d Ar device
-.Op Fl p Ar channel
 .Op Fl n
 .Ar name ...
 .Nm
 .Op Fl d Ar device
-.Op Fl p Ar channel
 .Op Fl n
 .Fl w
 .Ar name=value ...
@@ -71,11 +68,6 @@ flag can be used to give an alternative 
 .Pa /dev/audioctl0 .
 .Pp
 The
-.Fl p
-flag can be used to give a virtual channel to control, the default is a new
-channel.
-.Pp
-The
 .Fl n
 flag suppresses printing of the variable name.
 .Sh ENVIRONMENT
@@ -93,10 +85,10 @@ audio control device
 audio I/O device (does not reset on open)
 .El
 .Sh EXAMPLES
-To set the playing sampling rate to 11025, for the channel 3 you can use
-.Dl audioctl -p 3 -w play.sample_rate=11025
+To set the playing sampling rate to 11025, you can use
+.Dl audioctl -w play.sample_rate=11025
 To set all of the play parameters for CD-quality audio, you can use
-.Dl audioctl -p 3 -w play=44100,2,16,slinear_le
+.Dl audioctl -w play=44100,2,16,slinear_le
 Note that many of the variables that can be inspected and changed with
 .Nm
 are reset when

Index: src/usr.bin/audio/ctl/ctl.c
diff -u src/usr.bin/audio/ctl/ctl.c:1.43 src/usr.bin/audio/ctl/ctl.c:1.44
--- src/usr.bin/audio/ctl/ctl.c:1.43	Tue Mar 21 07:04:29 2017
+++ src/usr.bin/audio/ctl/ctl.c	Wed May  8 14:44:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ctl.c,v 1.43 2017/03/21 07:04:29 nat Exp $	*/
+/*	$NetBSD: ctl.c,v 1.44 2019/05/08 14:44:42 isaki Exp $	*/
 
 /*
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: ctl.c,v 1.43 2017/03/21 07:04:29 nat Exp $");
+__RCSID("$NetBSD: ctl.c,v 1.44 2019/05/08 14:44:42 isaki Exp $");
 #endif
 
 
@@ -66,7 +66,6 @@ static char encbuf[1000];
 
 static int properties, fullduplex, rerror;
 
-int channel;
 int verbose;
 
 static struct field {
@@ -291,9 +290,6 @@ getinfo(int fd)
 {
 	int pos, i;
 
-	if (channel >= 0 && ioctl(fd, AUDIO_SETCHAN, &channel) < 0)
-		err(1, "AUDIO_SETCHAN");
-
 	if (ioctl(fd, AUDIO_GETDEV, &adev) < 0)
 		err(1, "AUDIO_GETDEV");
 	for (pos = 0, i = 0; ; i++) {
@@ -326,11 +322,9 @@ usage(void)
 {
 	const char *prog = getprogname();
 
-	fprintf(stderr, "Usage: %s [-d file] [-p] channel "
-			"[-n] name ...\n", prog);
-	fprintf(stderr, "Usage: %s [-d file] [-p] channel [-n] "
-			"-w name=value ...\n", prog);
-	fprintf(stderr, "Usage: %s [-d file] [-p] channel [-n] -a\n", prog);
+	fprintf(stderr, "Usage: %s [-d file] [-n] name ...\n", prog);
+	fprintf(stderr, "Usage: %s [-d file] [-n] -w name=value ...\n", prog);
+	fprintf(stderr, "Usage: %s [-d file] [-n] -a\n", prog);
 	exit(1);
 }
 
@@ -343,12 +337,11 @@ main(int argc, char *argv[])
 	const char *file;
 	const char *sep = "=";
 
-	channel = -1;
 	file = getenv("AUDIOCTLDEVICE");
 	if (file == NULL)
 		file = deffile;
 
-	while ((ch = getopt(argc, argv, "ad:f:np:w")) != -1) {
+	while ((ch = getopt(argc, argv, "ad:f:nw")) != -1) {
 		switch(ch) {
 		case 'a':
 			aflag++;
@@ -359,9 +352,6 @@ main(int argc, char *argv[])
 		case 'n':
 			sep = 0;
 			break;
-		case 'p':
-			channel = atoi(optarg);
-			break;
 		case 'f': /* compatibility */
 		case 'd':
 			file = optarg;
@@ -440,9 +430,6 @@ audioctl_write(int fd, int argc, char *a
 {
 	struct field *p;
 
-	if (channel >= 0 && ioctl(fd, AUDIO_SETCHAN, &channel) < 0)
-		err(1, "AUDIO_SETCHAN");
-
 	AUDIO_INITINFO(&info);
 	while (argc--) {
 		char *q;



CVS commit: src/usr.bin/audiocfg

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 14:36:12 UTC 2019

Modified Files:
src/usr.bin/audiocfg: audiocfg.1 audiodev.c audiodev.h main.c

Log Message:
Update respond to isaki-audio2 branch.
- Extend list command to display supported hardware formats.
- Add set command to set hardware format.
- Use correct /dev/audioctl instead of /dev/audio.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/audiocfg/audiocfg.1
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/audiocfg/audiodev.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/audiocfg/audiodev.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/audiocfg/main.c

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

Modified files:

Index: src/usr.bin/audiocfg/audiocfg.1
diff -u src/usr.bin/audiocfg/audiocfg.1:1.3 src/usr.bin/audiocfg/audiocfg.1:1.4
--- src/usr.bin/audiocfg/audiocfg.1:1.3	Wed Sep  1 09:17:31 2010
+++ src/usr.bin/audiocfg/audiocfg.1	Wed May  8 14:36:12 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audiocfg.1,v 1.3 2010/09/01 09:17:31 wiz Exp $
+.\"	$NetBSD: audiocfg.1,v 1.4 2019/05/08 14:36:12 isaki Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -40,6 +40,14 @@
 .Cm default
 .Ar index
 .Nm
+.Cm set
+.Ar index
+.Ar direction
+.Ar encoding
+.Ar precision
+.Ar channels
+.Ar sample_rate
+.Nm
 .Cm test
 .Ar index
 .Sh DESCRIPTION
@@ -51,6 +59,25 @@ Run with
 .Dq Cm list ,
 it lists the available audio devices and shows the currently selected
 default audio device.
+.Pp
+Run with
+.Dq Cm set ,
+if sets the hardware format.
+The
+.Ar direction
+is represented by either of 'p'(playback) or 'r'(record), or both of them,
+indicates direction you want to set to.
+The remaining parameters
+.Ar encoding ,
+.Ar precision ,
+.Ar channels
+and
+.Ar sample_rate
+indicate the hardware format you want to set to.
+These parameters must be selected from the candidates displayed by
+.Nm
+.Cm list .
+.Pp
 Called with
 .Dq Cm test ,
 it plays a tone of 2 seconds for each channel of the device with the index

Index: src/usr.bin/audiocfg/audiodev.c
diff -u src/usr.bin/audiocfg/audiodev.c:1.6 src/usr.bin/audiocfg/audiodev.c:1.7
--- src/usr.bin/audiocfg/audiodev.c:1.6	Sat Mar  5 22:10:39 2016
+++ src/usr.bin/audiocfg/audiodev.c	Wed May  8 14:36:12 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audiodev.c,v 1.6 2016/03/05 22:10:39 mrg Exp $ */
+/* $NetBSD: audiodev.c,v 1.7 2019/05/08 14:36:12 isaki Exp $ */
 
 /*
  * Copyright (c) 2010 Jared D. McNeill 
@@ -31,6 +31,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -47,51 +48,23 @@ static TAILQ_HEAD(audiodevhead, audiodev
 
 #define AUDIODEV_SAMPLE_RATE	44100
 
-static unsigned int
-audiodev_probe_pchans(struct audiodev *adev)
-{
-	audio_info_t info;
-	unsigned int nchans = 0, n;
-	int error;
-
-	AUDIO_INITINFO(&info);
-	info.play.sample_rate = AUDIODEV_SAMPLE_RATE;
-	info.play.precision = 16;
-	info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
-	info.play.channels = 1;
-	info.mode = AUMODE_PLAY;
-	error = ioctl(adev->fd, AUDIO_SETINFO, &info);
-	if (error == -1)
-		return 0;
-	nchans = 1;
-
-	for (n = 2; n <= 16; n += 2) {
-		info.play.channels = n;
-		error = ioctl(adev->fd, AUDIO_SETINFO, &info);
-		if (error == -1)
-			break;
-		nchans = info.play.channels;
-	}
-
-	return nchans;
-}
-
 static int
 audiodev_getinfo(struct audiodev *adev)
 {
 	struct stat st;
+	struct audiofmt *f;
+	audio_format_query_t query;
+	int i;
 
-	if (stat(adev->path, &st) == -1)
+	if (stat(adev->ctlpath, &st) == -1)
 		return -1;
 	adev->dev = st.st_rdev;
 
-	if (stat(_PATH_AUDIO, &st) != -1 && st.st_rdev == adev->dev)
+	if (stat(_PATH_AUDIOCTL, &st) != -1 && st.st_rdev == adev->dev)
 		adev->defaultdev = true;
 
-	adev->fd = open(adev->path, O_RDWR);
+	adev->fd = open(adev->ctlpath, O_RDONLY);
 	if (adev->fd == -1) {
-		adev->fd = open(adev->path, O_WRONLY);
-		if (adev->fd == -1)
 			return -1;
 	}
 	if (ioctl(adev->fd, AUDIO_GETDEV, &adev->audio_device) == -1) {
@@ -99,7 +72,29 @@ audiodev_getinfo(struct audiodev *adev)
 		return -1;
 	}
 
-	adev->pchan = audiodev_probe_pchans(adev);
+	for (i = 0; ;i++) {
+		memset(&query, 0, sizeof(query));
+		query.index = i;
+		if (ioctl(adev->fd, AUDIO_QUERYFORMAT, &query) == -1) {
+			if (errno == ENODEV) {
+/* QUERYFORMAT not supported. */
+break;
+			}
+			if (errno == EINVAL)
+break;
+			close(adev->fd);
+			return -1;
+		}
+
+		f = calloc(1, sizeof(*f));
+		f->fmt = query.fmt;
+		TAILQ_INSERT_TAIL(&adev->formats, f, next);
+	}
+
+	if (ioctl(adev->fd, AUDIO_GETFORMAT, &adev->info) == -1) {
+		close(adev->fd);
+		return -1;
+	}
 
 	return 0;
 }
@@ -115,8 +110,10 @@ audiodev_add(const char *pdev, const cha
 
 	strlcpy(adev->pxname, pdev, sizeof(adev->pxname));
 	strlcpy(adev->xname, dev, sizeof(adev->xname));
-	snprintf(adev->path, sizeof(adev->path) - 1, "/dev/%s", dev);
+	snprintf(adev->path, sizeof(adev->path), "/dev/%s", dev);
+	snprintf(adev->ctlpath, sizeof(

CVS commit: src

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 14:25:39 UTC 2019

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man4: audio.4
src/share/man/man9: Makefile audio.9 intro.9
Removed Files:
src/share/man/man9: audio_system.9

Log Message:
Update manpages respond to isaki-audio2 branch.


To generate a diff of this commit:
cvs rdiff -u -r1.2272 -r1.2273 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.87 -r1.88 src/share/man/man4/audio.4
cvs rdiff -u -r1.436 -r1.437 src/share/man/man9/Makefile
cvs rdiff -u -r1.51 -r1.52 src/share/man/man9/audio.9
cvs rdiff -u -r1.1 -r0 src/share/man/man9/audio_system.9
cvs rdiff -u -r1.23 -r1.24 src/share/man/man9/intro.9

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2272 src/distrib/sets/lists/comp/mi:1.2273
--- src/distrib/sets/lists/comp/mi:1.2272	Sat Apr 27 23:04:31 2019
+++ src/distrib/sets/lists/comp/mi	Wed May  8 14:25:38 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2272 2019/04/27 23:04:31 kamil Exp $
+#	$NetBSD: mi,v 1.2273 2019/05/08 14:25:38 isaki Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -10654,7 +10654,7 @@
 ./usr/share/man/cat9/arpresolve.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/atop.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/audio.0			comp-sys-catman		.cat
-./usr/share/man/cat9/audio_system.0		comp-sys-catman		.cat
+./usr/share/man/cat9/audio_system.0		comp-sys-catman		obsolete
 ./usr/share/man/cat9/autoconf.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/bawrite.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/bcdtobin.0			comp-sys-catman		.cat
@@ -18591,7 +18591,7 @@
 ./usr/share/man/html9/arpresolve.html		comp-sys-htmlman	html
 ./usr/share/man/html9/atop.html			comp-sys-htmlman	html
 ./usr/share/man/html9/audio.html		comp-sys-htmlman	html
-./usr/share/man/html9/audio_system.html		comp-sys-htmlman	html
+./usr/share/man/html9/audio_system.html		comp-sys-htmlman	obsolete
 ./usr/share/man/html9/autoconf.html		comp-sys-htmlman	html
 ./usr/share/man/html9/bawrite.html		comp-sys-htmlman	html
 ./usr/share/man/html9/bcdtobin.html		comp-sys-htmlman	html
@@ -26631,7 +26631,7 @@
 ./usr/share/man/man9/arpresolve.9		comp-sys-man		.man
 ./usr/share/man/man9/atop.9			comp-sys-man		.man
 ./usr/share/man/man9/audio.9			comp-sys-man		.man
-./usr/share/man/man9/audio_system.9		comp-sys-man		.man
+./usr/share/man/man9/audio_system.9		comp-sys-man		obsolete
 ./usr/share/man/man9/autoconf.9			comp-sys-man		.man
 ./usr/share/man/man9/bawrite.9			comp-sys-man		.man
 ./usr/share/man/man9/bcdtobin.9			comp-sys-man		.man

Index: src/share/man/man4/audio.4
diff -u src/share/man/man4/audio.4:1.87 src/share/man/man4/audio.4:1.88
--- src/share/man/man4/audio.4:1.87	Sat Feb 16 06:50:14 2019
+++ src/share/man/man4/audio.4	Wed May  8 14:25:39 2019
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audio.4,v 1.87 2019/02/16 06:50:14 isaki Exp $
+.\"	$NetBSD: audio.4,v 1.88 2019/05/08 14:25:39 isaki Exp $
 .\"
 .\" Copyright (c) 1996 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -66,137 +66,40 @@ accepts the same
 operations as
 .Pa /dev/sound ,
 but no other operations.
+It can be opened at any time and can be used to manipulate the
+audio device while it is in use.
 .Pp
-.Pa /dev/sound
-and
-.Pa /dev/audio
-can be opened at
-.Em any
-time and audio sources of different precision and playback
-parameters i.e frequency will be mixed and played back simultaneously.
-.Pp
-.Pa /dev/audioctl
-can be used to manipulate the audio device
-while it is in use.
 .Sh SAMPLING DEVICES
 When
 .Pa /dev/audio
-is opened, it automatically directs the underlying driver to manipulate
-monaural 8-bit mu-law samples.
-In addition, if it is opened read-only
-(write-only) the device is set to half-duplex record (play) mode with
-recording (playing) unpaused and playing (recording) paused.
+is opened, it automatically sets the track to manipulate
+monaural 8-bit mu-law 8000Hz.
 When
 .Pa /dev/sound
-is opened, it maintains the previous audio sample mode and
-record/playback mode most recently set on
-.Pa /dev/sound
-by any open channel.
+is opened, it maintains the audio format and pause/unpause
+state of the most recently opened track.
 In all other respects
 .Pa /dev/audio
 and
 .Pa /dev/sound
 are identical.
-.Sh VIRTUAL CHANNELS
-Any process may open a sampling device at a given time.
-Any number of devices per process and file descriptors may be shared between
-processes.
-.Pp
-Virtual channels are converted to a common format, signed linear encoding,
-frequency channels and precision.
-These can be modified to taste by the following
-.Xr sysctl 8
-variables:
-.Bl -tag -width "hw.driverN.precision" -compact -offset indent
-.It Li hw. Ns Ar driverN Ns Li .precision
-.It Li hw. Ns Ar driverN Ns Li .frequency
-.

CVS commit: src/sys/sys

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 13:47:33 UTC 2019

Modified Files:
src/sys/sys: param.h

Log Message:
Merge isaki-audio2 branch.

Welcome to 8.99.39.


To generate a diff of this commit:
cvs rdiff -u -r1.586 -r1.587 src/sys/sys/param.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/sys/param.h
diff -u src/sys/sys/param.h:1.586 src/sys/sys/param.h:1.587
--- src/sys/sys/param.h:1.586	Mon May  6 08:07:41 2019
+++ src/sys/sys/param.h	Wed May  8 13:47:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.586 2019/05/06 08:07:41 kamil Exp $	*/
+/*	$NetBSD: param.h,v 1.587 2019/05/08 13:47:33 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	899003800	/* NetBSD 8.99.38 */
+#define	__NetBSD_Version__	899003900	/* NetBSD 8.99.39 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 13:40:20 UTC 2019

Modified Files:
src/sys/arch/amiga/conf: files.amiga
src/sys/arch/amiga/dev: aucc.c melody.c repulse.c toccata.c
src/sys/arch/amigappc/conf: files.amigappc
src/sys/arch/arm/broadcom: bcm2835_vcaudio.c files.bcm2835
src/sys/arch/arm/imx: imx23_digfilt.c
src/sys/arch/arm/iomd: files.iomd vidcaudio.c
src/sys/arch/arm/sunxi: files.sunxi sun4i_a10_codec.c
sun50i_a64_acodec.c sun6i_a31_codec.c sun8i_codec.c
sun8i_h3_codec.c sunxi_codec.c sunxi_codec.h sunxi_i2s.c
src/sys/arch/arm/xscale: files.pxa2x0 pxa2x0_ac97.c pxa2x0_i2s.c
pxa2x0_i2s.h
src/sys/arch/dreamcast/conf: files.dreamcast
src/sys/arch/dreamcast/dev/g2: aica.c
src/sys/arch/evbarm/conf: files.mini2440
src/sys/arch/evbarm/mini2440: audio_mini2440.c
src/sys/arch/hp300/dev: arcofi_dio.c
src/sys/arch/hpcmips/vr: vraiu.c
src/sys/arch/hppa/conf: files.hppa
src/sys/arch/hppa/gsc: harmony.c harmonyvar.h
src/sys/arch/i386/pnpbios: ess_pnpbios.c sb_pnpbios.c wss_pnpbios.c
ym_pnpbios.c
src/sys/arch/ibmnws/conf: files.ibmnws
src/sys/arch/macppc/conf: files.macppc
src/sys/arch/macppc/dev: awacs.c snapper.c
src/sys/arch/mips/conf: files.alchemy
src/sys/arch/prep/conf: files.prep
src/sys/arch/prep/isa: paud_isa.c
src/sys/arch/sgimips/hpc: files.hpc haltwo.c
src/sys/arch/sgimips/mace: files.mace mavb.c
src/sys/arch/sparc/conf: GENERIC TADPOLE3GX
src/sys/arch/sparc/dev: audioamd.c
src/sys/arch/usermode/conf: files.usermode
src/sys/arch/usermode/dev: vaudio.c
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: thunk.c
src/sys/arch/vax/vsa: vsaudio.c
src/sys/arch/x68k/conf: files.x68k
src/sys/arch/x68k/dev: vs.c vsvar.h
src/sys/arch/zaurus/conf: files.zaurus
src/sys/arch/zaurus/dev: wm8731_zaudio.c wm8750_zaudio.c zaudio.c
zaudiovar.h
src/sys/dev: DEVNAMES files.audio midi.c midisyn.c spkr_audio.c
src/sys/dev/acpi: wss_acpi.c ym_acpi.c
src/sys/dev/bluetooth: btsco.c files.bluetooth
src/sys/dev/ebus: cs4231_ebus.c
src/sys/dev/fdt: ausoc.c fdtvar.h
src/sys/dev/hdaudio: files.hdaudio hdafg.c hdaudiovar.h
src/sys/dev/ic: ac97.c ad1848.c ad1848var.h am7930.c am7930var.h
arcofi.c arcofivar.h cs4231.c interwave.c interwavevar.h msm6258.c
msm6258var.h opl.c pl041.c pl041var.h tms320av110.c
tms320av110var.h uda1341.c uda1341var.h
src/sys/dev/isa: ad1848_isa.c ad1848var.h aria.c cms.c ess.c files.isa
gus.c ics2101.c joy_ess.c midi_pcppi.c mpu_sb.c mpu_ym.c opl_ess.c
opl_isa.c opl_sb.c opl_wss.c opl_ym.c pas.c sb.c sb_isa.c sbdsp.c
sbdspvar.h wss.c wss_isa.c ym.c
src/sys/dev/isapnp: ess_isapnp.c gus_isapnp.c mpu_isapnp.c sb_isapnp.c
wss_isapnp.c ym_isapnp.c
src/sys/dev/ofisa: ess_ofisa.c sb_ofisa.c
src/sys/dev/pad: files.pad pad.c padvar.h
src/sys/dev/pci: auacer.c auich.c auixp.c auixpvar.h autri.c auvia.c
auviavar.h azalia.c azalia.h cmpci.c cs4280.c cs4280reg.h cs4281.c
cs428x.c cs428x.h eap.c emuxki.c esa.c esm.c esmvar.h eso.c
esoreg.h files.pci fms.c gcscaudio.c joy_eap.c joy_eso.c
mpu_cmpci.c mpu_eso.c mpu_fms.c mpu_yds.c neo.c opl_cmpci.c
opl_eso.c opl_fms.c opl_sv.c opl_yds.c sv.c yds.c ydsvar.h
src/sys/dev/pci/igma: files.igma
src/sys/dev/pci/voyager: files.voyager
src/sys/dev/sbus: cs4231_sbus.c dbri.c dbrivar.h files.sbus
src/sys/dev/tc: bba.c files.tc
src/sys/dev/usb: files.usb uaudio.c umidi.c umidi_quirks.c
src/sys/modules/audio: Makefile
src/sys/modules/spkr: Makefile
src/sys/rump/dev/lib/libaudio: Makefile audio_component.c
src/sys/sys: audioio.h file.h
Added Files:
src/sys/dev/audio: alaw.c audio.c audio_dai.h audio_if.h audiobell.c
audiobellvar.h audiodef.h audiofil.h audiovar.h linear.c linear.h
mulaw.c mulaw.h
Removed Files:
src/sys/dev: auconv.c auconv.h audio.c audio_dai.h audio_if.h
audiobell.c audiobelldata.h audiobellvar.h audiovar.h aurateconv.c
auvolconv.c auvolconv.h mulaw.c mulaw.h
src/sys/dev/pci: emuxkivar.h
src/sys/rump/dev/lib/libaudio: aurateconv.h mulaw.h

Log Message:
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly.  Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism.  The encoding/cha

CVS commit: [isaki-audio2] src/sys/modules/spkr

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 12:48:01 UTC 2019

Modified Files:
src/sys/modules/spkr [isaki-audio2]: Makefile

Log Message:
Add WARNS flag.  (It was left at my local in previous commit..)


To generate a diff of this commit:
cvs rdiff -u -r1.8.2.1 -r1.8.2.2 src/sys/modules/spkr/Makefile

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

Modified files:

Index: src/sys/modules/spkr/Makefile
diff -u src/sys/modules/spkr/Makefile:1.8.2.1 src/sys/modules/spkr/Makefile:1.8.2.2
--- src/sys/modules/spkr/Makefile:1.8.2.1	Tue May  7 15:01:50 2019
+++ src/sys/modules/spkr/Makefile	Wed May  8 12:48:01 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8.2.1 2019/05/07 15:01:50 isaki Exp $
+# $NetBSD: Makefile,v 1.8.2.2 2019/05/08 12:48:01 isaki Exp $
 
 .include "../Makefile.inc"
 
@@ -14,6 +14,8 @@ SRCS+=	spkr_audio.c
 .PATH:	${S}/dev/audio
 SRCS+=	audiobell.c
 
+WARNS=	3
+
 CPPFLAGS+=	-DNWSMUX=1
 
 .include 



CVS commit: [isaki-audio2] src/sys/dev/audio

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 11:57:53 UTC 2019

Modified Files:
src/sys/dev/audio [isaki-audio2]: audio_if.h

Log Message:
Good bye stream_filter.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/dev/audio/audio_if.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/dev/audio/audio_if.h
diff -u src/sys/dev/audio/audio_if.h:1.1.2.1 src/sys/dev/audio/audio_if.h:1.1.2.2
--- src/sys/dev/audio/audio_if.h:1.1.2.1	Sat May  4 07:20:09 2019
+++ src/sys/dev/audio/audio_if.h	Wed May  8 11:57:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio_if.h,v 1.1.2.1 2019/05/04 07:20:09 isaki Exp $	*/
+/*	$NetBSD: audio_if.h,v 1.1.2.2 2019/05/08 11:57:52 isaki Exp $	*/
 
 /*
  * Copyright (c) 1994 Havard Eidnes.
@@ -72,107 +72,6 @@ typedef struct audio_params {
 #define	AUFMT_VALIDATE(fmt)	(fmt)->mode &= 0x7fff
 #define	AUFMT_IS_VALID(fmt)	(((fmt)->mode & 0x8000) == 0)
 
-/**
- * audio stream buffer
- */
-typedef struct audio_stream {
-	size_t bufsize;		/* allocated memory */
-	uint8_t *start;		/* start of buffer area */
-	uint8_t *end;		/* end of valid buffer area */
-	uint8_t *inp;		/* address to be written next */
-	const uint8_t *outp;	/* address to be read next */
-	int used;		/* valid data size in this stream */
-	audio_params_t param;	/* represents this stream */
-	bool loop;
-} audio_stream_t;
-
-static __inline int
-audio_stream_get_space(const audio_stream_t *s)
-{
-	if (s)
-		return (s->end - s->start) - s->used;
-	return 0;
-}
-
-static __inline int
-audio_stream_get_used(const audio_stream_t *s)
-{
-	return s ? s->used : 0;
-}
-
-static __inline uint8_t *
-audio_stream_add_inp(audio_stream_t *s, uint8_t *v, int diff)
-{
-	s->used += diff;
-	v += diff;
-	if (v >= s->end)
-		v -= s->end - s->start;
-	return v;
-}
-
-static __inline const uint8_t *
-audio_stream_add_outp(audio_stream_t *s, const uint8_t *v, int diff)
-{
-	s->used -= diff;
-	v += diff;
-	if (v >= s->end)
-		v -= s->end - s->start;
-	return v;
-}
-
-/**
- * an interface to fill a audio stream buffer
- */
-typedef struct stream_fetcher {
-	int (*fetch_to)(struct audio_softc *, struct stream_fetcher *,
-audio_stream_t *, int);
-} stream_fetcher_t;
-
-/**
- * audio stream filter.
- * This must be an extension of stream_fetcher_t.
- */
-typedef struct stream_filter {
-/* public: */
-	stream_fetcher_t base;
-	void (*dtor)(struct stream_filter *);
-	void (*set_fetcher)(struct stream_filter *, stream_fetcher_t *);
-	void (*set_inputbuffer)(struct stream_filter *, audio_stream_t *);
-/* private: */
-	stream_fetcher_t *prev;
-	audio_stream_t *src;
-} stream_filter_t;
-
-/**
- * factory method for stream_filter_t
- */
-typedef stream_filter_t *stream_filter_factory_t(struct audio_softc *,
-	const audio_params_t *, const audio_params_t *);
-
-/**
- * filter pipeline request
- *
- * filters[0] is the first filter for playing or the last filter for recording.
- * The audio_params_t instance for the hardware is filters[0].param.
- */
-#ifndef AUDIO_MAX_FILTERS
-# define AUDIO_MAX_FILTERS	8
-#endif
-typedef struct stream_filter_list {
-	void (*append)(struct stream_filter_list *, stream_filter_factory_t,
-		   const audio_params_t *);
-	void (*prepend)(struct stream_filter_list *, stream_filter_factory_t,
-			const audio_params_t *);
-	void (*set)(struct stream_filter_list *, int, stream_filter_factory_t,
-		const audio_params_t *);
-	int req_size;
-	struct stream_filter_req {
-		stream_filter_factory_t *factory;
-		audio_params_t param; /* from-param for recording,
-	 to-param for playing */
-	} filters[AUDIO_MAX_FILTERS];
-} stream_filter_list_t;
-
 #include 
 
 struct audio_hw_if {
@@ -232,7 +131,6 @@ struct audio_hw_if {
 		void (*)(void *), void *, const audio_params_t *);
 	int	(*dev_ioctl)(void *, u_long, void *, int, struct lwp *);
 	void	(*get_locks)(void *, kmutex_t **, kmutex_t **);
-
 };
 
 struct audio_attach_args {



CVS commit: [isaki-audio2] src/sys/arch/vax/vsa

2019-05-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  8 11:56:09 UTC 2019

Modified Files:
src/sys/arch/vax/vsa [isaki-audio2]: vsaudio.c

Log Message:
Remove commented out old filters.


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/arch/vax/vsa/vsaudio.c

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/vax/vsa/vsaudio.c
diff -u src/sys/arch/vax/vsa/vsaudio.c:1.4.2.2 src/sys/arch/vax/vsa/vsaudio.c:1.4.2.3
--- src/sys/arch/vax/vsa/vsaudio.c:1.4.2.2	Sat May  4 07:20:08 2019
+++ src/sys/arch/vax/vsa/vsaudio.c	Wed May  8 11:56:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsaudio.c,v 1.4.2.2 2019/05/04 07:20:08 isaki Exp $	*/
+/*	$NetBSD: vsaudio.c,v 1.4.2.3 2019/05/08 11:56:09 isaki Exp $	*/
 /*	$OpenBSD: vsaudio.c,v 1.4 2013/05/15 21:21:11 ratchov Exp $	*/
 
 /*
@@ -516,57 +516,4 @@ vsaudio_get_locks(void *opaque, kmutex_t
 	*thread = &sc->sc_lock;
 }
 
-/*
-static stream_filter_t *
-vsaudio_input_conv(struct audio_softc *sc, const audio_params_t *from,
-		const audio_params_t *to)
-{
-	return auconv_nocontext_filter_factory(vsaudio_input_conv_fetch_to);
-}
-
-static int
-vsaudio_input_conv_fetch_to(struct audio_softc *sc, stream_fetcher_t *self,
-		audio_stream_t *dst, int max_used)
-{
-	stream_filter_t *this;
-	int m, err;
-
-	this = (stream_filter_t *)self;
-	if ((err = this->prev->fetch_to(sc, this->prev, this->src, max_used * 4)))
-		return err;
-	m = dst->end - dst->start;
-	m = uimin(m, max_used);
-	FILTER_LOOP_PROLOGUE(this->src, 4, dst, 1, m) {
-		*d = ((*(const uint32_t *)s) >> 16) & 0xff;
-	} FILTER_LOOP_EPILOGUE(this->src, dst);
-	return 0;
-}
-
-static stream_filter_t *
-vsaudio_output_conv(struct audio_softc *sc, const audio_params_t *from,
-		const audio_params_t *to)
-{
-	return auconv_nocontext_filter_factory(vsaudio_output_conv_fetch_to);
-}
-
-static int
-vsaudio_output_conv_fetch_to(struct audio_softc *sc, stream_fetcher_t *self,
-		audio_stream_t *dst, int max_used)
-{
-	stream_filter_t *this;
-	int m, err;
-
-	this = (stream_filter_t *)self;
-	max_used = (max_used + 3) & ~3;
-	if ((err = this->prev->fetch_to(sc, this->prev, this->src, max_used / 4)))
-		return err;
-	m = (dst->end - dst->start) & ~3;
-	m = uimin(m, max_used);
-	FILTER_LOOP_PROLOGUE(this->src, 1, dst, 4, m) {
-		*(uint32_t *)d = (*s << 16);
-	} FILTER_LOOP_EPILOGUE(this->src, dst);
-	return 0;
-}
-*/
-
 #endif /* NAUDIO > 0 */



CVS commit: [isaki-audio2] src/sys

2019-05-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue May  7 15:01:50 UTC 2019

Modified Files:
src/sys/modules/audio [isaki-audio2]: Makefile
src/sys/modules/spkr [isaki-audio2]: Makefile
src/sys/rump/dev/lib/libaudio [isaki-audio2]: Makefile
Removed Files:
src/sys/rump/dev/lib/libaudio [isaki-audio2]: aurateconv.h mulaw.h

Log Message:
Fix paths and flags.
- aurateconv is gone.  mulaw is a part of audio inseparably.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.2.1 src/sys/modules/audio/Makefile
cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/modules/spkr/Makefile
cvs rdiff -u -r1.6 -r1.6.12.1 src/sys/rump/dev/lib/libaudio/Makefile
cvs rdiff -u -r1.1 -r0 src/sys/rump/dev/lib/libaudio/aurateconv.h \
src/sys/rump/dev/lib/libaudio/mulaw.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/modules/audio/Makefile
diff -u src/sys/modules/audio/Makefile:1.3 src/sys/modules/audio/Makefile:1.3.2.1
--- src/sys/modules/audio/Makefile:1.3	Sun Feb 17 04:05:43 2019
+++ src/sys/modules/audio/Makefile	Tue May  7 15:01:50 2019
@@ -1,18 +1,17 @@
-#	$NetBSD: Makefile,v 1.3 2019/02/17 04:05:43 rin Exp $
+#	$NetBSD: Makefile,v 1.3.2.1 2019/05/07 15:01:50 isaki Exp $
 
 .include "../Makefile.inc"
 
-.PATH:	${S}/dev
+.PATH:	${S}/dev/audio
 
 KMOD=	audio
 IOCONF=	audio.ioconf
 SRCS=	audio.c \
-	auconv.c \
-	aurateconv.c \
-	auvolconv.c \
+	alaw.c \
+	linear.c \
 	mulaw.c
 
-CPPFLAGS+=	-DNAUDIO=1 -DNAURATECONV=1 -DNMULAW=1
+CPPFLAGS+=	-DNAUDIO=1
 
 WARNS=	3
 

Index: src/sys/modules/spkr/Makefile
diff -u src/sys/modules/spkr/Makefile:1.8 src/sys/modules/spkr/Makefile:1.8.2.1
--- src/sys/modules/spkr/Makefile:1.8	Sun Feb 17 04:05:58 2019
+++ src/sys/modules/spkr/Makefile	Tue May  7 15:01:50 2019
@@ -1,15 +1,18 @@
-# $NetBSD: Makefile,v 1.8 2019/02/17 04:05:58 rin Exp $
+# $NetBSD: Makefile,v 1.8.2.1 2019/05/07 15:01:50 isaki Exp $
 
 .include "../Makefile.inc"
 
-.PATH:	${S}/dev/isa ${S}/dev
+.PATH:	${S}/dev/isa
 
 KMOD=	spkr
 IOCONF=	spkr.ioconf
 SRCS=	spkr.c spkr_pcppi.c
 
 .PATH:	${S}/dev
-SRCS+=	spkr_audio.c audiobell.c
+SRCS+=	spkr_audio.c
+
+.PATH:	${S}/dev/audio
+SRCS+=	audiobell.c
 
 CPPFLAGS+=	-DNWSMUX=1
 

Index: src/sys/rump/dev/lib/libaudio/Makefile
diff -u src/sys/rump/dev/lib/libaudio/Makefile:1.6 src/sys/rump/dev/lib/libaudio/Makefile:1.6.12.1
--- src/sys/rump/dev/lib/libaudio/Makefile:1.6	Thu Jun  1 09:44:30 2017
+++ src/sys/rump/dev/lib/libaudio/Makefile	Tue May  7 15:01:50 2019
@@ -1,17 +1,17 @@
-#	$NetBSD: Makefile,v 1.6 2017/06/01 09:44:30 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.6.12.1 2019/05/07 15:01:50 isaki Exp $
 #
 
-.PATH:	${.CURDIR}/../../../../dev
+.PATH:	${.CURDIR}/../../../../dev/audio
 
 LIB=	rumpdev_audio
 COMMENT=Audio support (incl. /dev/audio and /dev/mixer)
 
 IOCONF=	AUDIO.ioconf
 
-SRCS=	audio.c auconv.c aurateconv.c auvolconv.c mulaw.c
+SRCS=	alaw.c audio.c linear.c mulaw.c
 SRCS+=	audio_component.c
 
-CPPFLAGS+=	-DNAUDIO=1 -DNAURATECONV=1 -DNMULAW=1
+CPPFLAGS+=	-DNAUDIO=1
 
 .include 
 .include 



CVS commit: [isaki-audio2] src/sys/dev/pad

2019-05-06 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Mon May  6 13:40:03 UTC 2019

Modified Files:
src/sys/dev/pad [isaki-audio2]: pad.c

Log Message:
Revive clonify.
XXX should clean code more.


To generate a diff of this commit:
cvs rdiff -u -r1.58.2.3 -r1.58.2.4 src/sys/dev/pad/pad.c

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

Modified files:

Index: src/sys/dev/pad/pad.c
diff -u src/sys/dev/pad/pad.c:1.58.2.3 src/sys/dev/pad/pad.c:1.58.2.4
--- src/sys/dev/pad/pad.c:1.58.2.3	Sun May  5 02:01:34 2019
+++ src/sys/dev/pad/pad.c	Mon May  6 13:40:03 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.58.2.3 2019/05/05 02:01:34 isaki Exp $ */
+/* $NetBSD: pad.c,v 1.58.2.4 2019/05/06 13:40:03 isaki Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill 
@@ -27,23 +27,25 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.58.2.3 2019/05/05 02:01:34 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.58.2.4 2019/05/06 13:40:03 isaki Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -57,6 +59,8 @@ __KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.58
 #define DPRINTF(fmt...) /**/
 #endif
 
+#define MAXDEVS		128
+#define PADCLONER	254
 #define PADUNIT(x)	minor(x)
 
 #define PADFREQ		44100
@@ -64,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.58
 #define PADPREC		16
 
 extern struct cfdriver pad_cd;
+kmutex_t padconfig;
 
 typedef struct pad_block {
 	uint8_t		*pb_ptr;
@@ -85,8 +90,8 @@ static void	pad_childdet(device_t, devic
 
 static int	pad_query_format(void *, audio_format_query_t *);
 static int	pad_set_format(void *, int,
-const audio_params_t *, const audio_params_t *,
-			audio_filter_reg_t *, audio_filter_reg_t *);
+		const audio_params_t *, const audio_params_t *,
+		audio_filter_reg_t *, audio_filter_reg_t *);
 static int	pad_start_output(void *, void *, int,
 void (*)(void *), void *);
 static int	pad_start_input(void *, void *, int,
@@ -103,7 +108,18 @@ static void	pad_get_locks(void *, kmutex
 static void	pad_done_output(void *);
 static void	pad_swvol_codec(audio_filter_arg_t *);
 
-static bool	pad_is_attached;	/* Do we have an audio* child? */
+static int pad_close(struct pad_softc *);
+static int pad_read(struct pad_softc *, off_t *, struct uio *, kauth_cred_t, int);
+
+static int fops_pad_close(struct file *);
+static int fops_pad_read(struct file *, off_t *, struct uio *, kauth_cred_t, int);
+static int pad_write(struct file *, off_t *, struct uio *, kauth_cred_t, int);
+static int pad_ioctl(struct file *, u_long, void *);
+static int pad_kqfilter(struct file *, struct knote *);
+static int pad_poll(struct file *, int);
+static int pad_stat(struct file *, struct stat *);
+static int pad_mmap(struct file *, off_t *, size_t, int, int *, int *,
+			   struct uvm_object **, int *);
 
 static const struct audio_hw_if pad_hw_if = {
 	.query_format = pad_query_format,
@@ -121,14 +137,9 @@ static const struct audio_hw_if pad_hw_i
 };
 
 #define PAD_NFORMATS	1
-#if defined(PAD_SUPPORT_RECORD)
-#define PADMODE	(AUMODE_PLAY | AUMODE_RECORD)
-#else
-#define PADMODE	AUMODE_PLAY
-#endif
 static const struct audio_format pad_formats[PAD_NFORMATS] = {
 	{
-		.mode		= PADMODE,
+		.mode		= AUMODE_PLAY,
 		.encoding	= AUDIO_ENCODING_SLINEAR_NE,
 		.validbits	= PADPREC,
 		.precision	= PADPREC,
@@ -144,14 +155,14 @@ extern void	padattach(int);
 static int	pad_add_block(pad_softc_t *, uint8_t *, int);
 static int	pad_get_block(pad_softc_t *, pad_block_t *, int);
 
-dev_type_open(pad_dev_open);
-dev_type_close(pad_dev_close);
-dev_type_read(pad_dev_read);
+dev_type_open(pad_open);
+dev_type_close(cdev_pad_close);
+dev_type_read(cdev_pad_read);
 
 const struct cdevsw pad_cdevsw = {
-	.d_open = pad_dev_open,
-	.d_close = pad_dev_close,
-	.d_read = pad_dev_read,
+	.d_open = pad_open,
+	.d_close = cdev_pad_close,
+	.d_read = cdev_pad_read,
 	.d_write = nowrite,
 	.d_ioctl = noioctl,
 	.d_stop = nostop,
@@ -163,35 +174,36 @@ const struct cdevsw pad_cdevsw = {
 	.d_flag = D_OTHER | D_MPSAFE,
 };
 
+const struct fileops pad_fileops = {
+	.fo_name = "pad",
+	.fo_read = fops_pad_read,
+	.fo_write = pad_write,
+	.fo_ioctl = pad_ioctl,
+	.fo_fcntl = fnullop_fcntl,
+	.fo_stat = pad_stat,
+	.fo_poll = pad_poll,
+	.fo_close = fops_pad_close,
+	.fo_mmap = pad_mmap,
+	.fo_kqfilter = pad_kqfilter,
+	.fo_restart = fnullop_restart
+};
+
 CFATTACH_DECL2_NEW(pad, sizeof(pad_softc_t), pad_match, pad_attach, pad_detach,
 NULL, NULL, pad_childdet);
 
 void
 padattach(int n)
 {
-	int i, err;
-	cfdata_t cf;
+	int error;
 
-	aprint_debug("pad: requested %d units\n", n);
-	DPRINTF("%s: requested %d units\n", __func__, n);
-
-	err = config_cfattach_attach(pad_cd.cd_name, &pad_ca);
-	if (err) {
+	error = config_cfattach_attach(pad_cd.cd_name

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun May  5 05:59:40 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: cs4280.c cs4280reg.h cs428x.h

Log Message:
Remove encoding conversions on recording.
These are handled in the upper layer now.


To generate a diff of this commit:
cvs rdiff -u -r1.71.2.2 -r1.71.2.3 src/sys/dev/pci/cs4280.c
cvs rdiff -u -r1.7 -r1.7.156.1 src/sys/dev/pci/cs4280reg.h
cvs rdiff -u -r1.16.42.1 -r1.16.42.2 src/sys/dev/pci/cs428x.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/dev/pci/cs4280.c
diff -u src/sys/dev/pci/cs4280.c:1.71.2.2 src/sys/dev/pci/cs4280.c:1.71.2.3
--- src/sys/dev/pci/cs4280.c:1.71.2.2	Sat May  4 07:20:10 2019
+++ src/sys/dev/pci/cs4280.c	Sun May  5 05:59:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cs4280.c,v 1.71.2.2 2019/05/04 07:20:10 isaki Exp $	*/
+/*	$NetBSD: cs4280.c,v 1.71.2.3 2019/05/05 05:59:40 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Tatoku Ogaito.  All rights reserved.
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cs4280.c,v 1.71.2.2 2019/05/04 07:20:10 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cs4280.c,v 1.71.2.3 2019/05/05 05:59:40 isaki Exp $");
 
 #include "midi.h"
 
@@ -450,9 +450,6 @@ cs4280_intr(void *p)
 	}
 	/* Capture Interrupt */
 	if (intr & HISR_CINT) {
-		int  i;
-		int16_t rdata;
-
 		handled = 1;
 		mem = BA1READ4(sc, CS4280_CIE);
 		BA1WRITE4(sc, CS4280_CIE, (mem & ~CIE_CI_MASK) | CIE_CI_DISABLE);
@@ -463,53 +460,9 @@ cs4280_intr(void *p)
 			if ((sc->sc_ri&1) == 0)
 empty_dma += sc->hw_blocksize;
 
-			/*
-			 * XXX
-			 * I think this audio data conversion should be
-			 * happend in upper layer, but I put this here
-			 * since there is no conversion function available.
-			 */
-			switch(sc->sc_rparam) {
-			case CF_16BIT_STEREO:
-/* just copy it */
-memcpy(sc->sc_rn, empty_dma, sc->hw_blocksize);
-sc->sc_rn += sc->hw_blocksize;
-break;
-			case CF_16BIT_MONO:
-for (i = 0; i < 512; i++) {
-	rdata  = *((int16_t *)empty_dma)>>1;
-	empty_dma += 2;
-	rdata += *((int16_t *)empty_dma)>>1;
-	empty_dma += 2;
-	*((int16_t *)sc->sc_rn) = rdata;
-	sc->sc_rn += 2;
-}
-break;
-			case CF_8BIT_STEREO:
-for (i = 0; i < 512; i++) {
-	rdata = *((int16_t*)empty_dma);
-	empty_dma += 2;
-	*sc->sc_rn++ = rdata >> 8;
-	rdata = *((int16_t*)empty_dma);
-	empty_dma += 2;
-	*sc->sc_rn++ = rdata >> 8;
-}
-break;
-			case CF_8BIT_MONO:
-for (i = 0; i < 512; i++) {
-	rdata =	 *((int16_t*)empty_dma) >>1;
-	empty_dma += 2;
-	rdata += *((int16_t*)empty_dma) >>1;
-	empty_dma += 2;
-	*sc->sc_rn++ = rdata >>8;
-}
-break;
-			default:
-/* Should not reach here */
-aprint_error_dev(sc->sc_dev,
-"unknown sc->sc_rparam: %d\n",
-sc->sc_rparam);
-			}
+			/* just copy it */
+			memcpy(sc->sc_rn, empty_dma, sc->hw_blocksize);
+			sc->sc_rn += sc->hw_blocksize;
 			if (sc->sc_rn >= sc->sc_re)
 sc->sc_rn = sc->sc_rs;
 		}
@@ -752,17 +705,6 @@ cs4280_trigger_input(void *addr, void *s
 	/* initiate capture DMA */
 	BA1WRITE4(sc, CS4280_CBA, DMAADDR(p));
 
-	/* setup format information for internal converter */
-	sc->sc_rparam = 0;
-	if (param->precision == 8) {
-		sc->sc_rparam += CF_8BIT;
-		sc->sc_rcount <<= 1;
-	}
-	if (param->channels  == 1) {
-		sc->sc_rparam += CF_MONO;
-		sc->sc_rcount <<= 1;
-	}
-
 	/* set CIE */
 	cie = BA1READ4(sc, CS4280_CIE) & ~CIE_CI_MASK;
 	BA1WRITE4(sc, CS4280_CIE, cie | CIE_CI_ENABLE);

Index: src/sys/dev/pci/cs4280reg.h
diff -u src/sys/dev/pci/cs4280reg.h:1.7 src/sys/dev/pci/cs4280reg.h:1.7.156.1
--- src/sys/dev/pci/cs4280reg.h:1.7	Sat Apr 15 21:20:47 2006
+++ src/sys/dev/pci/cs4280reg.h	Sun May  5 05:59:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cs4280reg.h,v 1.7 2006/04/15 21:20:47 jmcneill Exp $	*/
+/*	$NetBSD: cs4280reg.h,v 1.7.156.1 2019/05/05 05:59:40 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Tatoku Ogaito.  All rights reserved.
@@ -217,14 +217,6 @@
 #define	 FRMT_FTV	  0x0adf
 
 
-#define CF_MONO		  0x01
-#define CF_8BIT		  0x02
-
-#define CF_16BIT_STEREO	  0x00
-#define CF_16BIT_MONO	  0x01
-#define CF_8BIT_STEREO	  0x02
-#define CF_8BIT_MONO	  0x03
-
 #define MIDI_BUSY_WAIT		100
 #define MIDI_BUSY_DELAY		100	/* Delay when UART is busy */
 

Index: src/sys/dev/pci/cs428x.h
diff -u src/sys/dev/pci/cs428x.h:1.16.42.1 src/sys/dev/pci/cs428x.h:1.16.42.2
--- src/sys/dev/pci/cs428x.h:1.16.42.1	Sun Apr 21 07:49:16 2019
+++ src/sys/dev/pci/cs428x.h	Sun May  5 05:59:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cs428x.h,v 1.16.42.1 2019/04/21 07:49:16 isaki Exp $	*/
+/*	$NetBSD: cs428x.h,v 1.16.42.2 2019/05/05 05:59:40 isaki Exp $	*/
 
 /*
  * Copyright (c) 2000 Tatoku Ogaito.  All rights reserved.
@@ -118,7 +118,6 @@ struct cs428x_softc {
 	int	sc_ri;
 	struct	cs428x_dma *sc_rdma;
 	char	*sc_rbuf;
-	int	sc_rparam;		/* record format */
 	int	(*halt

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun May  5 03:11:28 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: auixpvar.h

Log Message:
Remove sc_encodings. (I forgot it)


To generate a diff of this commit:
cvs rdiff -u -r1.8.42.2 -r1.8.42.3 src/sys/dev/pci/auixpvar.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/dev/pci/auixpvar.h
diff -u src/sys/dev/pci/auixpvar.h:1.8.42.2 src/sys/dev/pci/auixpvar.h:1.8.42.3
--- src/sys/dev/pci/auixpvar.h:1.8.42.2	Sat Apr 27 13:10:03 2019
+++ src/sys/dev/pci/auixpvar.h	Sun May  5 03:11:28 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: auixpvar.h,v 1.8.42.2 2019/04/27 13:10:03 isaki Exp $*/
+/* $NetBSD: auixpvar.h,v 1.8.42.3 2019/05/05 03:11:28 isaki Exp $*/
 
 /*
  * Copyright (c) 2004, 2005 Reinoud Zandijk 
@@ -119,7 +119,6 @@ struct auixp_softc {
 
 	/* audio formats supported */
 	struct audio_format sc_formats[AUIXP_NFORMATS];
-	struct audio_encoding_set *sc_encodings;
 
 	/* codecs */
 	int			sc_num_codecs;



CVS commit: [isaki-audio2] src/sys

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun May  5 02:31:42 UTC 2019

Modified Files:
src/sys/arch/amiga/conf [isaki-audio2]: files.amiga
src/sys/arch/amigappc/conf [isaki-audio2]: files.amigappc
src/sys/arch/arm/broadcom [isaki-audio2]: files.bcm2835
src/sys/arch/arm/iomd [isaki-audio2]: files.iomd
src/sys/arch/arm/sunxi [isaki-audio2]: files.sunxi
src/sys/arch/arm/xscale [isaki-audio2]: files.pxa2x0
src/sys/arch/dreamcast/conf [isaki-audio2]: files.dreamcast
src/sys/arch/evbarm/conf [isaki-audio2]: files.mini2440
src/sys/arch/hppa/conf [isaki-audio2]: files.hppa
src/sys/arch/ibmnws/conf [isaki-audio2]: files.ibmnws
src/sys/arch/macppc/conf [isaki-audio2]: files.macppc
src/sys/arch/mips/conf [isaki-audio2]: files.alchemy
src/sys/arch/prep/conf [isaki-audio2]: files.prep
src/sys/arch/sgimips/hpc [isaki-audio2]: files.hpc
src/sys/arch/sgimips/mace [isaki-audio2]: files.mace
src/sys/arch/usermode/conf [isaki-audio2]: files.usermode
src/sys/arch/x68k/conf [isaki-audio2]: files.x68k
src/sys/arch/zaurus/conf [isaki-audio2]: files.zaurus
src/sys/dev [isaki-audio2]: DEVNAMES
src/sys/dev/bluetooth [isaki-audio2]: files.bluetooth
src/sys/dev/hdaudio [isaki-audio2]: files.hdaudio
src/sys/dev/isa [isaki-audio2]: files.isa
src/sys/dev/pad [isaki-audio2]: files.pad
src/sys/dev/pci [isaki-audio2]: files.pci
src/sys/dev/pci/igma [isaki-audio2]: files.igma
src/sys/dev/pci/voyager [isaki-audio2]: files.voyager
src/sys/dev/sbus [isaki-audio2]: files.sbus
src/sys/dev/tc [isaki-audio2]: files.tc
src/sys/dev/usb [isaki-audio2]: files.usb

Log Message:
Remove obsoleted au{,rate,vol}conv and mulaw attributes.
audio provides the equivalent of them inseparably.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.181.2.1 src/sys/arch/amiga/conf/files.amiga
cvs rdiff -u -r1.30 -r1.30.2.1 src/sys/arch/amigappc/conf/files.amigappc
cvs rdiff -u -r1.32 -r1.32.2.1 src/sys/arch/arm/broadcom/files.bcm2835
cvs rdiff -u -r1.19 -r1.19.94.1 src/sys/arch/arm/iomd/files.iomd
cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r1.20 -r1.20.4.1 src/sys/arch/arm/xscale/files.pxa2x0
cvs rdiff -u -r1.31 -r1.31.18.1 src/sys/arch/dreamcast/conf/files.dreamcast
cvs rdiff -u -r1.1 -r1.1.54.1 src/sys/arch/evbarm/conf/files.mini2440
cvs rdiff -u -r1.20 -r1.20.2.1 src/sys/arch/hppa/conf/files.hppa
cvs rdiff -u -r1.13 -r1.13.56.1 src/sys/arch/ibmnws/conf/files.ibmnws
cvs rdiff -u -r1.110 -r1.110.4.1 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r1.13 -r1.13.146.1 src/sys/arch/mips/conf/files.alchemy
cvs rdiff -u -r1.62 -r1.62.40.1 src/sys/arch/prep/conf/files.prep
cvs rdiff -u -r1.16 -r1.16.4.1 src/sys/arch/sgimips/hpc/files.hpc
cvs rdiff -u -r1.10 -r1.10.110.1 src/sys/arch/sgimips/mace/files.mace
cvs rdiff -u -r1.18 -r1.18.2.1 src/sys/arch/usermode/conf/files.usermode
cvs rdiff -u -r1.82 -r1.82.2.1 src/sys/arch/x68k/conf/files.x68k
cvs rdiff -u -r1.15 -r1.15.4.1 src/sys/arch/zaurus/conf/files.zaurus
cvs rdiff -u -r1.320 -r1.320.2.1 src/sys/dev/DEVNAMES
cvs rdiff -u -r1.15 -r1.15.8.1 src/sys/dev/bluetooth/files.bluetooth
cvs rdiff -u -r1.3 -r1.3.24.1 src/sys/dev/hdaudio/files.hdaudio
cvs rdiff -u -r1.172 -r1.172.2.1 src/sys/dev/isa/files.isa
cvs rdiff -u -r1.5 -r1.5.24.1 src/sys/dev/pad/files.pad
cvs rdiff -u -r1.412 -r1.412.2.1 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.1 -r1.1.40.1 src/sys/dev/pci/igma/files.igma
cvs rdiff -u -r1.6 -r1.6.42.1 src/sys/dev/pci/voyager/files.voyager
cvs rdiff -u -r1.43.2.1 -r1.43.2.2 src/sys/dev/sbus/files.sbus
cvs rdiff -u -r1.34 -r1.34.20.1 src/sys/dev/tc/files.tc
cvs rdiff -u -r1.154 -r1.154.2.1 src/sys/dev/usb/files.usb

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/amiga/conf/files.amiga
diff -u src/sys/arch/amiga/conf/files.amiga:1.181 src/sys/arch/amiga/conf/files.amiga:1.181.2.1
--- src/sys/arch/amiga/conf/files.amiga:1.181	Wed Dec 19 13:57:45 2018
+++ src/sys/arch/amiga/conf/files.amiga	Sun May  5 02:31:39 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.amiga,v 1.181 2018/12/19 13:57:45 maxv Exp $
+#	$NetBSD: files.amiga,v 1.181.2.1 2019/05/05 02:31:39 isaki Exp $
 
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16			# NOTE THAT AMIGA IS SPECIAL!
@@ -118,11 +118,11 @@ device	melody: audiobus, tms320av110
 attach	melody at zbus
 file	arch/amiga/dev/melody.c		melody
 
-device repulse: audiobus, ac97, mulaw
+device repulse: audiobus, ac97
 attach	repulse at zbus
 file	arch/amiga/dev/repulse.c	repulse
 
-device toccata: audiobus, ad1848, auconv
+device toccata: audiobus, ad1848
 attach	toccata at zbus
 file	arch/amiga/dev/toccata.c	toccata
 

Index: src/sys/arch/amigappc/conf/files.amigappc
diff -u src/sys/arch/

CVS commit: [isaki-audio2] src/sys/dev/audio

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun May  5 02:20:36 UTC 2019

Modified Files:
src/sys/dev/audio [isaki-audio2]: audio.c audiovar.h

Log Message:
Revive multiuser control.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.8 -r1.1.2.9 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/dev/audio/audiovar.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/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.1.2.8 src/sys/dev/audio/audio.c:1.1.2.9
--- src/sys/dev/audio/audio.c:1.1.2.8	Sat May  4 07:41:50 2019
+++ src/sys/dev/audio/audio.c	Sun May  5 02:20:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.1.2.8 2019/05/04 07:41:50 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.1.2.9 2019/05/05 02:20:36 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -149,7 +149,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.8 2019/05/04 07:41:50 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.9 2019/05/05 02:20:36 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -577,6 +577,7 @@ static int audio_mixers_set_format(struc
 static void audio_mixers_get_format(struct audio_softc *, struct audio_info *);
 static int audio_sysctl_volume(SYSCTLFN_PROTO);
 static int audio_sysctl_blk_ms(SYSCTLFN_PROTO);
+static int audio_sysctl_multiuser(SYSCTLFN_PROTO);
 #if defined(AUDIO_DEBUG)
 static int audio_sysctl_debug(SYSCTLFN_PROTO);
 #endif
@@ -993,6 +994,13 @@ audioattach(device_t parent, device_t se
 		audio_sysctl_blk_ms, 0, (void *)sc, 0,
 		CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
 
+		sysctl_createv(&sc->sc_log, 0, NULL, NULL,
+		CTLFLAG_READWRITE,
+		CTLTYPE_BOOL, "multiuser",
+		SYSCTL_DESCR("allow multiple user access"),
+		audio_sysctl_multiuser, 0, (void *)sc, 0,
+		CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
+
 #if defined(AUDIO_DEBUG)
 		sysctl_createv(&sc->sc_log, 0, NULL, NULL,
 		CTLFLAG_READWRITE,
@@ -2070,9 +2078,9 @@ audio_open(dev_t dev, struct audio_softc
 	goto bad3;
 			}
 		}
-	} else /* if (sc->sc_multiuser == false) XXX not yet */ {
+	} else if (sc->sc_multiuser == false) {
 		uid_t euid = kauth_cred_geteuid(kauth_cred_get());
-		if (euid != 0 && kauth_cred_geteuid(sc->sc_cred) != euid) {
+		if (euid != 0 && euid != kauth_cred_geteuid(sc->sc_cred)) {
 			error = EPERM;
 			goto bad2;
 		}
@@ -7480,6 +7488,34 @@ abort:
 	return error;
 }
 
+/*
+ * Get or set multiuser mode.
+ */
+static int
+audio_sysctl_multiuser(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node;
+	struct audio_softc *sc;
+	int t, error;
+
+	node = *rnode;
+	sc = node.sysctl_data;
+
+	mutex_enter(sc->sc_lock);
+
+	t = sc->sc_multiuser;
+	node.sysctl_data = &t;
+	error = sysctl_lookup(SYSCTLFN_CALL(&node));
+	if (error || newp == NULL)
+		goto abort;
+
+	sc->sc_multiuser = t;
+	error = 0;
+abort:
+	mutex_exit(sc->sc_lock);
+	return error;
+}
+
 #if defined(AUDIO_DEBUG)
 /*
  * Get or set debug verbose level. (0..4)

Index: src/sys/dev/audio/audiovar.h
diff -u src/sys/dev/audio/audiovar.h:1.1.2.2 src/sys/dev/audio/audiovar.h:1.1.2.3
--- src/sys/dev/audio/audiovar.h:1.1.2.2	Sat May  4 07:20:09 2019
+++ src/sys/dev/audio/audiovar.h	Sun May  5 02:20:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiovar.h,v 1.1.2.2 2019/05/04 07:20:09 isaki Exp $	*/
+/*	$NetBSD: audiovar.h,v 1.1.2.3 2019/05/05 02:20:36 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -221,6 +221,12 @@ struct audio_softc {
 	 */
 	bool		sc_dying;
 
+	/*
+	 * If multiuser is false, other users who have different euid
+	 * than the first user cannot open this device.
+	 * Must be protected by sc_lock.
+	 */
+	bool sc_multiuser;
 	kauth_cred_t sc_cred;
 
 	struct sysctllog *sc_log;



CVS commit: [isaki-audio2] src/sys/dev/pad

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun May  5 02:01:34 UTC 2019

Modified Files:
src/sys/dev/pad [isaki-audio2]: pad.c

Log Message:
Remove unnecessary __diagused (which was imported in this branch).


To generate a diff of this commit:
cvs rdiff -u -r1.58.2.2 -r1.58.2.3 src/sys/dev/pad/pad.c

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

Modified files:

Index: src/sys/dev/pad/pad.c
diff -u src/sys/dev/pad/pad.c:1.58.2.2 src/sys/dev/pad/pad.c:1.58.2.3
--- src/sys/dev/pad/pad.c:1.58.2.2	Sat May  4 07:20:10 2019
+++ src/sys/dev/pad/pad.c	Sun May  5 02:01:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.58.2.2 2019/05/04 07:20:10 isaki Exp $ */
+/* $NetBSD: pad.c,v 1.58.2.3 2019/05/05 02:01:34 isaki Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.58.2.2 2019/05/04 07:20:10 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.58.2.3 2019/05/05 02:01:34 isaki Exp $");
 
 #include 
 #include 
@@ -401,7 +401,7 @@ pad_set_format(void *opaque, int setmode
 const audio_params_t *play, const audio_params_t *rec,
 	audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
-	pad_softc_t *sc __diagused;
+	pad_softc_t *sc;
 
 	sc = (pad_softc_t *)opaque;
 



CVS commit: [isaki-audio2] src/sys/dev/isa

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun May  5 01:57:06 UTC 2019

Modified Files:
src/sys/dev/isa [isaki-audio2]: sbdsp.c

Log Message:
Fix typos (made in this branch).


To generate a diff of this commit:
cvs rdiff -u -r1.139.2.3 -r1.139.2.4 src/sys/dev/isa/sbdsp.c

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

Modified files:

Index: src/sys/dev/isa/sbdsp.c
diff -u src/sys/dev/isa/sbdsp.c:1.139.2.3 src/sys/dev/isa/sbdsp.c:1.139.2.4
--- src/sys/dev/isa/sbdsp.c:1.139.2.3	Sat May  4 07:20:10 2019
+++ src/sys/dev/isa/sbdsp.c	Sun May  5 01:57:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbdsp.c,v 1.139.2.3 2019/05/04 07:20:10 isaki Exp $	*/
+/*	$NetBSD: sbdsp.c,v 1.139.2.4 2019/05/05 01:57:06 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sbdsp.c,v 1.139.2.3 2019/05/04 07:20:10 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbdsp.c,v 1.139.2.4 2019/05/05 01:57:06 isaki Exp $");
 
 #include "midi.h"
 #include "mpu.h"
@@ -462,7 +462,7 @@ sbdsp_attach(struct sbdsp_softc *sc)
 		}
 	}
 
-	/* Construct sc_format from model */
+	/* Construct sc_formats from model */
 	sbdsp_init_format(sc);
 	if (sc->sc_nformats == 0) {
 		aprint_error_dev(sc->sc_dev,
@@ -597,7 +597,7 @@ sbdsp_init_format(struct sbdsp_softc *sc
 			idx = (m->precision / 16) * 2 + (m->channels - 1);
 			d = &dbase[idx];
 			if (d->mode == 0) {
-/* The first elements of this room */
+/* The first element of this room */
 *d = tmp;
 continue;
 			}



CVS commit: [isaki-audio2] src/sys/arch/sgimips/mace

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  4 12:03:04 UTC 2019

Modified Files:
src/sys/arch/sgimips/mace [isaki-audio2]: mavb.c

Log Message:
Correct precision.
Tested by naru@.  Thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.12.2.3 -r1.12.2.4 src/sys/arch/sgimips/mace/mavb.c

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/sgimips/mace/mavb.c
diff -u src/sys/arch/sgimips/mace/mavb.c:1.12.2.3 src/sys/arch/sgimips/mace/mavb.c:1.12.2.4
--- src/sys/arch/sgimips/mace/mavb.c:1.12.2.3	Sat May  4 07:20:08 2019
+++ src/sys/arch/sgimips/mace/mavb.c	Sat May  4 12:03:03 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: mavb.c,v 1.12.2.3 2019/05/04 07:20:08 isaki Exp $ */
+/* $NetBSD: mavb.c,v 1.12.2.4 2019/05/04 12:03:03 isaki Exp $ */
 /* $OpenBSD: mavb.c,v 1.6 2005/04/15 13:05:14 mickey Exp $ */
 
 /*
@@ -111,8 +111,8 @@ static const struct audio_format mavb_fo
 	{
 		.mode		= AUMODE_PLAY,
 		.encoding	= AUDIO_ENCODING_SLINEAR_BE,
-		.validbits	= 16,
-		.precision	= 16,
+		.validbits	= 24,
+		.precision	= 32,
 		.channels	= 2,
 		.channel_mask	= AUFMT_STEREO,
 		.frequency_type	= 0,



CVS commit: src/usr.bin/audio/play

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  4 08:27:30 UTC 2019

Modified Files:
src/usr.bin/audio/play: play.c

Log Message:
Use err(3)/errx(3) properly to avoid "write failed: Undefined error: 0".


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/audio/play/play.c

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

Modified files:

Index: src/usr.bin/audio/play/play.c
diff -u src/usr.bin/audio/play/play.c:1.56 src/usr.bin/audio/play/play.c:1.57
--- src/usr.bin/audio/play/play.c:1.56	Fri Nov 16 13:55:17 2018
+++ src/usr.bin/audio/play/play.c	Sat May  4 08:27:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: play.c,v 1.56 2018/11/16 13:55:17 mlelstv Exp $	*/
+/*	$NetBSD: play.c,v 1.57 2019/05/04 08:27:30 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000, 2001, 2002, 2010 Matthew R. Green
@@ -28,7 +28,7 @@
 #include 
 
 #ifndef lint
-__RCSID("$NetBSD: play.c,v 1.56 2018/11/16 13:55:17 mlelstv Exp $");
+__RCSID("$NetBSD: play.c,v 1.57 2019/05/04 08:27:30 isaki Exp $");
 #endif
 
 
@@ -224,6 +224,7 @@ play(char *file)
 	off_t datasize = 0;
 	ssize_t	hdrlen;
 	int fd;
+	int nw;
 
 	if (file[0] == '-' && file[1] == 0) {
 		play_fd("standard input", STDIN_FILENO);
@@ -283,13 +284,19 @@ play(char *file)
 	}
 
 	while ((uint64_t)datasize > bufsize) {
-		if ((size_t)write(audiofd, addr, bufsize) != bufsize)
+		nw = write(audiofd, addr, bufsize);
+		if (nw == -1)
 			err(1, "write failed");
+		if ((size_t)nw != bufsize)
+			errx(1, "write failed");
 		addr = (char *)addr + bufsize;
 		datasize -= bufsize;
 	}
-	if ((off_t)write(audiofd, addr, datasize) != datasize)
+	nw = write(audiofd, addr, datasize);
+	if (nw == -1)
 		err(1, "final write failed");
+	if ((off_t)nw != datasize)
+		errx(1, "final write failed");
 
 	if (ioctl(audiofd, AUDIO_DRAIN) < 0 && !qflag)
 		warn("audio drain ioctl failed");
@@ -341,8 +348,10 @@ play_fd(const char *file, int fd)
 		if (datasize != 0 && dataout + nr > datasize)
 			nr = datasize - dataout;
 		nw = write(audiofd, buffer, nr);
+		if (nw == -1)
+			err(1, "audio device write failed");
 		if (nw != nr)
-			goto write_error;
+			errx(1, "audio device write failed");
 		dataout += nw;
 		nr = read(fd, buffer, bufsize);
 		if (nr == -1)
@@ -356,8 +365,6 @@ play_fd(const char *file, int fd)
 	return;
 read_error:
 	err(1, "read of standard input failed");
-write_error:
-	err(1, "audio device write failed");
 }
 
 /*



CVS commit: [isaki-audio2] src/sys/dev/audio

2019-05-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  4 07:41:50 UTC 2019

Modified Files:
src/sys/dev/audio [isaki-audio2]: audio.c

Log Message:
Improve comments.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.1.2.7 src/sys/dev/audio/audio.c:1.1.2.8
--- src/sys/dev/audio/audio.c:1.1.2.7	Sat May  4 07:20:09 2019
+++ src/sys/dev/audio/audio.c	Sat May  4 07:41:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.1.2.7 2019/05/04 07:20:09 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.1.2.8 2019/05/04 07:41:50 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -128,7 +128,7 @@
  *	get_locks 		-	-	Called at attach time
  *
  * *1 Note: Before 8.0, since these have been called only at attach time,
- *   neither lock were necessary.  In AUDIO2, on the other hand, since
+ *   neither lock were necessary.  Currently, on the other hand, since
  *   these may be also called after attach, the thread lock is required.
  *
  * In addition, there are two additional locks.
@@ -149,7 +149,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.7 2019/05/04 07:20:09 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.8 2019/05/04 07:41:50 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -6512,10 +6512,9 @@ audio_mixers_get_format(struct audio_sof
  *
  * ai.mode(R/W)
  *	It specifies the playback or recording mode, AUMODE_*.
- *	In AUDIO2, A mode change operation by ai.mode after opening is
- *	prohibited.
- *	In AUDIO2, AUMODE_PLAY_ALL no longer makes sense.  However, it's
- *	possible to get or to set for backward compatibility.
+ *	Currently, a mode change operation by ai.mode after opening is
+ *	prohibited.  In addition, AUMODE_PLAY_ALL no longer makes sense.
+ *	However, it's possible to get or to set for backward compatibility.
  *
  * ai.{hiwat,lowat}			(R/W)
  *	These specify the high water mark and low water mark for playback
@@ -6573,8 +6572,7 @@ audio_mixers_get_format(struct audio_sof
  *
  * ai.blocksize(R/-)
  *	It indicates the block size in bytes.
- *	XXX In AUDIO2, the blocksize of playback and recording may be
- *	different.
+ *	XXX The blocksize of playback and recording may be different.
  */
 
 /*



CVS commit: [isaki-audio2] src/sys

2019-05-04 Thread Tetsuya Isaki
+#include 
 
 static const struct audio_format vaudio_audio_formats[1] = {
 	{

Index: src/sys/arch/vax/vsa/vsaudio.c
diff -u src/sys/arch/vax/vsa/vsaudio.c:1.4.2.1 src/sys/arch/vax/vsa/vsaudio.c:1.4.2.2
--- src/sys/arch/vax/vsa/vsaudio.c:1.4.2.1	Mon Apr 22 13:29:34 2019
+++ src/sys/arch/vax/vsa/vsaudio.c	Sat May  4 07:20:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsaudio.c,v 1.4.2.1 2019/04/22 13:29:34 isaki Exp $	*/
+/*	$NetBSD: vsaudio.c,v 1.4.2.2 2019/05/04 07:20:08 isaki Exp $	*/
 /*	$OpenBSD: vsaudio.c,v 1.4 2013/05/15 21:21:11 ratchov Exp $	*/
 
 /*
@@ -77,7 +77,7 @@
 #include 
 
 #include 
-#include 
+#include 
 
 #include 
 #include 

Index: src/sys/arch/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.50.2.1 src/sys/arch/x68k/dev/vs.c:1.50.2.2
--- src/sys/arch/x68k/dev/vs.c:1.50.2.1	Sun Apr 21 14:00:19 2019
+++ src/sys/arch/x68k/dev/vs.c	Sat May  4 07:20:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.50.2.1 2019/04/21 14:00:19 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.50.2.2 2019/05/04 07:20:08 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.50.2.1 2019/04/21 14:00:19 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.50.2.2 2019/05/04 07:20:08 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.50.
 #include 
 
 #include 
-#include 
+#include 
 
 #include 
 #include 

Index: src/sys/arch/zaurus/dev/wm8731_zaudio.c
diff -u src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.2.4.2 src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.2.4.3
--- src/sys/arch/zaurus/dev/wm8731_zaudio.c:1.2.4.2	Sat May  4 04:13:23 2019
+++ src/sys/arch/zaurus/dev/wm8731_zaudio.c	Sat May  4 07:20:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wm8731_zaudio.c,v 1.2.4.2 2019/05/04 04:13:23 isaki Exp $	*/
+/*	$NetBSD: wm8731_zaudio.c,v 1.2.4.3 2019/05/04 07:20:09 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include "opt_zaudio.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wm8731_zaudio.c,v 1.2.4.2 2019/05/04 04:13:23 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wm8731_zaudio.c,v 1.2.4.3 2019/05/04 07:20:09 isaki Exp $");
 
 #include 
 #include 
@@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: wm8731_zaudi
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 

Index: src/sys/arch/zaurus/dev/wm8750_zaudio.c
diff -u src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.2.4.3 src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.2.4.4
--- src/sys/arch/zaurus/dev/wm8750_zaudio.c:1.2.4.3	Sat May  4 04:13:23 2019
+++ src/sys/arch/zaurus/dev/wm8750_zaudio.c	Sat May  4 07:20:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wm8750_zaudio.c,v 1.2.4.3 2019/05/04 04:13:23 isaki Exp $	*/
+/*	$NetBSD: wm8750_zaudio.c,v 1.2.4.4 2019/05/04 07:20:09 isaki Exp $	*/
 /*	$OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $	*/
 
 /*
@@ -51,7 +51,7 @@
 #include "opt_zaudio.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wm8750_zaudio.c,v 1.2.4.3 2019/05/04 04:13:23 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wm8750_zaudio.c,v 1.2.4.4 2019/05/04 07:20:09 isaki Exp $");
 
 #include 
 #include 
@@ -64,7 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: wm8750_zaudi
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 

Index: src/sys/arch/zaurus/dev/zaudio.c
diff -u src/sys/arch/zaurus/dev/zaudio.c:1.21.22.1 src/sys/arch/zaurus/dev/zaudio.c:1.21.22.2
--- src/sys/arch/zaurus/dev/zaudio.c:1.21.22.1	Wed Apr 24 13:03:06 2019
+++ src/sys/arch/zaurus/dev/zaudio.c	Sat May  4 07:20:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: zaudio.c,v 1.21.22.1 2019/04/24 13:03:06 isaki Exp $	*/
+/*	$NetBSD: zaudio.c,v 1.21.22.2 2019/05/04 07:20:09 isaki Exp $	*/
 /*	$OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $	*/
 
 /*
@@ -50,7 +50,7 @@
 #include "opt_cputypes.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zaudio.c,v 1.21.22.1 2019/04/24 13:03:06 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zaudio.c,v 1.21.22.2 2019/05/04 07:20:09 isaki Exp $");
 
 #include 
 #include 
@@ -59,7 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: zaudio.c,v 1
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 

Index: src/sys/dev/midi.c
diff -u src/sys/dev/midi.c:1.88 src/sys/dev/midi.c:1.88.8.1
--- src/sys/dev/midi.c:1.88	Sat Oct 28 03:47:24 2017
+++ src/sys/dev/midi.c	Sat May  4 07:20:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: midi.c,v 1.88 2017/10/28 03:47:24 riastradh Exp $	*/
+/*	$NetBSD: midi.c,v 1.88.8.1 2019/05/04 07:20:09 isaki Exp $	*/
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.88 2017/10/28 03:47:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.88.8.1 2019/05/04 07:20:09 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "midi.h"
@@ -57,7 +57,7 @@ __KERNEL_RCSID(0, "$

CVS commit: [isaki-audio2] src/sys

2019-05-03 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  4 06:35:16 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi [isaki-audio2]: sun50i_a64_acodec.c
sun8i_codec.c
src/sys/dev/fdt [isaki-audio2]: ausoc.c fdtvar.h
Added Files:
src/sys/dev/audio [isaki-audio2]: audio_dai.h
Removed Files:
src/sys/dev [isaki-audio2]: audio_dai.h

Log Message:
Move dev/audio_dai.h -> dev/audio/audio_dai.h


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.6.1 src/sys/arch/arm/sunxi/sun50i_a64_acodec.c
cvs rdiff -u -r1.5.6.1 -r1.5.6.2 src/sys/arch/arm/sunxi/sun8i_codec.c
cvs rdiff -u -r1.4.2.2 -r0 src/sys/dev/audio_dai.h
cvs rdiff -u -r0 -r1.1.2.1 src/sys/dev/audio/audio_dai.h
cvs rdiff -u -r1.3.8.2 -r1.3.8.3 src/sys/dev/fdt/ausoc.c
cvs rdiff -u -r1.50 -r1.50.2.1 src/sys/dev/fdt/fdtvar.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/sunxi/sun50i_a64_acodec.c
diff -u src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.8 src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.8.6.1
--- src/sys/arch/arm/sunxi/sun50i_a64_acodec.c:1.8	Wed May 16 10:23:43 2018
+++ src/sys/arch/arm/sunxi/sun50i_a64_acodec.c	Sat May  4 06:35:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_acodec.c,v 1.8 2018/05/16 10:23:43 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_acodec.c,v 1.8.6.1 2019/05/04 06:35:15 isaki Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun50i_a64_acodec.c,v 1.8 2018/05/16 10:23:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun50i_a64_acodec.c,v 1.8.6.1 2019/05/04 06:35:15 isaki Exp $");
 
 #include 
 #include 
@@ -36,7 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: sun50i_a64_a
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 

Index: src/sys/arch/arm/sunxi/sun8i_codec.c
diff -u src/sys/arch/arm/sunxi/sun8i_codec.c:1.5.6.1 src/sys/arch/arm/sunxi/sun8i_codec.c:1.5.6.2
--- src/sys/arch/arm/sunxi/sun8i_codec.c:1.5.6.1	Sat Apr 27 10:17:59 2019
+++ src/sys/arch/arm/sunxi/sun8i_codec.c	Sat May  4 06:35:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_codec.c,v 1.5.6.1 2019/04/27 10:17:59 isaki Exp $ */
+/* $NetBSD: sun8i_codec.c,v 1.5.6.2 2019/05/04 06:35:15 isaki Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.5.6.1 2019/04/27 10:17:59 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.5.6.2 2019/05/04 06:35:15 isaki Exp $");
 
 #include 
 #include 
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: sun8i_codec.
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 

Index: src/sys/dev/fdt/ausoc.c
diff -u src/sys/dev/fdt/ausoc.c:1.3.8.2 src/sys/dev/fdt/ausoc.c:1.3.8.3
--- src/sys/dev/fdt/ausoc.c:1.3.8.2	Sat May  4 04:13:24 2019
+++ src/sys/dev/fdt/ausoc.c	Sat May  4 06:35:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ausoc.c,v 1.3.8.2 2019/05/04 04:13:24 isaki Exp $ */
+/* $NetBSD: ausoc.c,v 1.3.8.3 2019/05/04 06:35:16 isaki Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.3.8.2 2019/05/04 04:13:24 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.3.8.3 2019/05/04 06:35:16 isaki Exp $");
 
 #include 
 #include 
@@ -38,7 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: ausoc.c,v 1.
 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 

Index: src/sys/dev/fdt/fdtvar.h
diff -u src/sys/dev/fdt/fdtvar.h:1.50 src/sys/dev/fdt/fdtvar.h:1.50.2.1
--- src/sys/dev/fdt/fdtvar.h:1.50	Wed Feb 27 17:01:57 2019
+++ src/sys/dev/fdt/fdtvar.h	Sat May  4 06:35:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.50 2019/02/27 17:01:57 jakllsch Exp $ */
+/* $NetBSD: fdtvar.h,v 1.50.2.1 2019/05/04 06:35:16 isaki Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -42,7 +42,7 @@
 #include "audio.h"
 #endif
 #if NAUDIO > 0
-#include 
+#include 
 #else
 typedef void *audio_dai_tag_t;
 #endif

Added files:

Index: src/sys/dev/audio/audio_dai.h
diff -u /dev/null src/sys/dev/audio/audio_dai.h:1.1.2.1
--- /dev/null	Sat May  4 06:35:16 2019
+++ src/sys/dev/audio/audio_dai.h	Sat May  4 06:35:16 2019
@@ -0,0 +1,291 @@
+/* $NetBSD: audio_dai.h,v 1.1.2.1 2019/05/04 06:35:16 isaki Exp $ */
+
+/*-
+ * Copyright (c) 2018 Jared McNeill 
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCL

CVS commit: [isaki-audio2] src/sys

2019-05-03 Thread Tetsuya Isaki
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 	/* 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 
 #include/* autoconfig functions */
@@ -78,7 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,
 #include 
 
 #include 
-#include 
+#include 
 #include 
 
 #include 

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 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__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 
 #include 
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: spkr_audio.c
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 #include 

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, SPEC

CVS commit: src/doc

2019-05-03 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  4 04:54:15 UTC 2019

Modified Files:
src/doc: BRANCHES

Log Message:
Add isaki-audio2 branch.


To generate a diff of this commit:
cvs rdiff -u -r1.348 -r1.349 src/doc/BRANCHES

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

Modified files:

Index: src/doc/BRANCHES
diff -u src/doc/BRANCHES:1.348 src/doc/BRANCHES:1.349
--- src/doc/BRANCHES:1.348	Mon Jan 28 00:43:54 2019
+++ src/doc/BRANCHES	Sat May  4 04:54:15 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: BRANCHES,v 1.348 2019/01/28 00:43:54 jdolecek Exp $
+#	$NetBSD: BRANCHES,v 1.349 2019/05/04 04:54:15 isaki Exp $
 #
 # This file contains a list of branches that exist in the NetBSD CVS
 # tree and their current state.
@@ -459,6 +459,17 @@ Maintainer:	Robert Swindells 
+Scope:		src/sys
+Notes:		Rework audio subsystem, including multiple streaming,
+		filter pipeline.
+
 Branch:		itohy-usb1
 Description:	USB stack overhaul, mostly DMA related
 Status:		Terminated



CVS commit: [isaki-audio2] src/sys

2019-05-03 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  4 04:51:21 UTC 2019

Modified Files:
src/sys/arch/amiga/dev [isaki-audio2]: aucc.c
src/sys/arch/evbarm/mini2440 [isaki-audio2]: audio_mini2440.c
src/sys/arch/hppa/gsc [isaki-audio2]: harmony.c harmonyvar.h
src/sys/dev/ic [isaki-audio2]: arcofi.c arcofivar.h

Log Message:
Remove simple flags that indicate whether the device is opened.
These are handled in the upper layer now.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.1 -r1.44.2.2 src/sys/arch/amiga/dev/aucc.c
cvs rdiff -u -r1.2.2.2 -r1.2.2.3 \
src/sys/arch/evbarm/mini2440/audio_mini2440.c
cvs rdiff -u -r1.5.2.1 -r1.5.2.2 src/sys/arch/hppa/gsc/harmony.c
cvs rdiff -u -r1.1.38.1 -r1.1.38.2 src/sys/arch/hppa/gsc/harmonyvar.h
cvs rdiff -u -r1.1.28.4 -r1.1.28.5 src/sys/dev/ic/arcofi.c
cvs rdiff -u -r1.1.28.1 -r1.1.28.2 src/sys/dev/ic/arcofivar.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/amiga/dev/aucc.c
diff -u src/sys/arch/amiga/dev/aucc.c:1.44.2.1 src/sys/arch/amiga/dev/aucc.c:1.44.2.2
--- src/sys/arch/amiga/dev/aucc.c:1.44.2.1	Sun Apr 21 09:33:54 2019
+++ src/sys/arch/amiga/dev/aucc.c	Sat May  4 04:51:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: aucc.c,v 1.44.2.1 2019/04/21 09:33:54 isaki Exp $ */
+/*	$NetBSD: aucc.c,v 1.44.2.2 2019/05/04 04:51:20 isaki Exp $ */
 
 /*
  * Copyright (c) 1999 Bernardo Innocenti
@@ -46,7 +46,7 @@
 #if NAUCC > 0
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aucc.c,v 1.44.2.1 2019/04/21 09:33:54 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aucc.c,v 1.44.2.2 2019/05/04 04:51:20 isaki Exp $");
 
 #include 
 #include 
@@ -98,7 +98,6 @@ extern struct audio_channel channel[4];
  * Software state.
  */
 struct aucc_softc {
-	int	sc_open;		/* single use device */
 	aucc_data_t sc_channel[4];	/* per channel freq, ... */
 	u_int	sc_encoding;		/* encoding AUDIO_ENCODING_.*/
 	int	sc_channels;		/* # of channels used */
@@ -312,9 +311,6 @@ aucc_open(void *addr, int flags)
 	sc = addr;
 	DPRINTF(("sa_open: unit %p\n",sc));
 
-	if (sc->sc_open)
-		return EBUSY;
-	sc->sc_open = 1;
 	for (i = 0; i < AUCC_MAXINT; i++) {
 		sc->sc_channel[i].nd_intr = NULL;
 		sc->sc_channel[i].nd_intrdata = NULL;
@@ -330,11 +326,6 @@ aucc_open(void *addr, int flags)
 void
 aucc_close(void *addr)
 {
-	struct aucc_softc *sc;
-
-	sc = addr;
-	DPRINTF(("sa_close: sc=%p\n", sc));
-	sc->sc_open = 0;
 
 	DPRINTF(("sa_close: closed.\n"));
 }

Index: src/sys/arch/evbarm/mini2440/audio_mini2440.c
diff -u src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.2 src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.3
--- src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.2	Wed May  1 13:45:52 2019
+++ src/sys/arch/evbarm/mini2440/audio_mini2440.c	Sat May  4 04:51:20 2019
@@ -66,8 +66,6 @@ struct uda_softc {
 	s3c2440_i2s_buf_t	sc_rec_buf;
 
 	void			*sc_i2s_handle;
-
-	bool			sc_open;
 };
 
 int	uda_ssio_open(void *, int);
@@ -161,7 +159,6 @@ uda_ssio_attach(device_t parent, device_
 
 	sc->sc_play_buf = NULL;
 	sc->sc_i2s_handle = aa->i2sa_handle;
-	sc->sc_open = false;
 
 	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
@@ -211,15 +208,10 @@ uda_ssio_attach(device_t parent, device_
 int
 uda_ssio_open(void *handle, int flags)
 {
-	struct uda1341_softc *uc = handle;
-	struct uda_softc *sc = uc->parent;
 	int retval;
 
 	DPRINTF(("%s\n", __func__));
 
-	if (sc->sc_open)
-		return EBUSY;
-
 	/* We only support write operations */
 	if (!(flags & FREAD) && !(flags & FWRITE))
 		return EINVAL;
@@ -233,20 +225,16 @@ uda_ssio_open(void *handle, int flags)
 		return retval;
 	}
 
-	sc->sc_open = true;
-
 	return 0; /* SUCCESS */
 }
 
 void
 uda_ssio_close(void *handle)
 {
-	struct uda1341_softc *uc = handle;
-	struct uda_softc *sc = uc->parent;
+
 	DPRINTF(("%s\n", __func__));
 
 	uda1341_close(handle);
-	sc->sc_open = false;
 }
 
 int

Index: src/sys/arch/hppa/gsc/harmony.c
diff -u src/sys/arch/hppa/gsc/harmony.c:1.5.2.1 src/sys/arch/hppa/gsc/harmony.c:1.5.2.2
--- src/sys/arch/hppa/gsc/harmony.c:1.5.2.1	Sun Apr 21 10:11:44 2019
+++ src/sys/arch/hppa/gsc/harmony.c	Sat May  4 04:51:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: harmony.c,v 1.5.2.1 2019/04/21 10:11:44 isaki Exp $	*/
+/*	$NetBSD: harmony.c,v 1.5.2.2 2019/05/04 04:51:20 isaki Exp $	*/
 
 /*	$OpenBSD: harmony.c,v 1.23 2004/02/13 21:28:19 mickey Exp $	*/
 
@@ -89,7 +89,6 @@
 #include 
 #include 
 
-int	harmony_open(void *, int);
 void	harmony_close(void *);
 int	harmony_query_format(void *, audio_format_query_t *);
 int	harmony_set_format(void *, int,
@@ -117,7 +116,6 @@ int	harmony_trigger_input(void *, void *
 void	harmony_get_locks(void *, kmutex_t **, kmutex_t **);
 
 const struct audio_hw_if harmony_sa_hw_if = {
-	.open			= harmony_open,
 	.close			= harmony_close,
 	.query_format		= harmony_query_format,
 	.set_format		= harmony_set_format,
@@ -420,18 +418,6

CVS commit: [isaki-audio2] src/sys/arch/hpcmips/vr

2019-05-03 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  4 04:44:03 UTC 2019

Modified Files:
src/sys/arch/hpcmips/vr [isaki-audio2]: vraiu.c

Log Message:
Remove sc_status flag.  Such flag that indicates whether the device
is opened is handled in the upper layer now.  And it also fixes that
was not able to call commit_setting() before open() since netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.16.2.1 -r1.16.2.2 src/sys/arch/hpcmips/vr/vraiu.c

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/hpcmips/vr/vraiu.c
diff -u src/sys/arch/hpcmips/vr/vraiu.c:1.16.2.1 src/sys/arch/hpcmips/vr/vraiu.c:1.16.2.2
--- src/sys/arch/hpcmips/vr/vraiu.c:1.16.2.1	Sun Apr 21 09:54:00 2019
+++ src/sys/arch/hpcmips/vr/vraiu.c	Sat May  4 04:44:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vraiu.c,v 1.16.2.1 2019/04/21 09:54:00 isaki Exp $	*/
+/*	$NetBSD: vraiu.c,v 1.16.2.2 2019/05/04 04:44:03 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 HAMAJIMA Katsuomi. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vraiu.c,v 1.16.2.1 2019/04/21 09:54:00 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vraiu.c,v 1.16.2.2 2019/05/04 04:44:03 isaki Exp $");
 
 #include 
 #include 
@@ -72,7 +72,6 @@ struct vraiu_softc {
 	vrcmu_chipset_tag_t	sc_cc;
 	void			*sc_handler;
 	u_short	*sc_buf;	/* DMA buffer pointer */
-	int	sc_status;	/* status */
 	u_int	sc_rate;	/* sampling rate */
 	u_char	sc_volume;	/* volume */
 	void	(*sc_intr)(void *);	/* interrupt routine */
@@ -106,8 +105,6 @@ const struct audio_format vraiu_formats 
 /*
  * Define our interface to the higher level audio driver.
  */
-int vraiu_open(void *, int);
-void vraiu_close(void *);
 int vraiu_query_format(void *, audio_format_query_t *);
 int vraiu_round_blocksize(void *, int, int, const audio_params_t *);
 int vraiu_commit_settings(void *);
@@ -127,8 +124,6 @@ int vraiu_get_props(void *);
 void vraiu_get_locks(void *, kmutex_t **, kmutex_t **);
 
 const struct audio_hw_if vraiu_hw_if = {
-	.open			= vraiu_open,
-	.close			= vraiu_close,
 	.query_format		= vraiu_query_format,
 	.set_format		= vraiu_set_format,
 	.round_blocksize	= vraiu_round_blocksize,
@@ -169,7 +164,6 @@ vraiu_attach(device_t parent, device_t s
 	va = aux;
 	sc = device_private(self);
 	sc->sc_dev = self;
-	sc->sc_status = ENXIO;
 	sc->sc_intr = NULL;
 	sc->sc_iot = va->va_iot;
 	sc->sc_vrip = va->va_vc;
@@ -253,7 +247,6 @@ vraiu_attach(device_t parent, device_t s
 	}
 	printf("\n");
 
-	sc->sc_status = 0;
 	sc->sc_rate = SPS8000;
 	DPRINTFN(1, ("vraiu_attach: reset AIU\n"))
 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, SEQ_REG_W, AIURST);
@@ -262,31 +255,6 @@ vraiu_attach(device_t parent, device_t s
 }
 
 int
-vraiu_open(void *self, int flags)
-{
-	struct vraiu_softc *sc;
-
-	DPRINTFN(1, ("vraiu_open\n"));
-	sc = self;
-	if (sc->sc_status) {
-		DPRINTFN(0, ("vraiu_open: device error\n"));
-		return sc->sc_status;
-	}
-	sc->sc_status = EBUSY;
-	return 0;
-}
-
-void
-vraiu_close(void *self)
-{
-	struct vraiu_softc *sc;
-
-	DPRINTFN(1, ("vraiu_close\n"));
-	sc = self;
-	sc->sc_status = 0;
-}
-
-int
 vraiu_query_format(void *self, audio_format_query_t *afp)
 {
 
@@ -340,8 +308,6 @@ vraiu_commit_settings(void *self)
 
 	DPRINTFN(1, ("vraiu_commit_settings\n"));
 	sc = self;
-	if (sc->sc_status != EBUSY)
-		return sc->sc_status;
 
 	DPRINTFN(1, ("vraiu_commit_settings: set conversion rate %d\n",
 		 sc->sc_rate))



CVS commit: [isaki-audio2] src/sys

2019-05-03 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  4 04:13:25 UTC 2019

Modified Files:
src/sys/arch/amiga/dev [isaki-audio2]: toccata.c
src/sys/arch/arm/imx [isaki-audio2]: imx23_digfilt.c
src/sys/arch/arm/sunxi [isaki-audio2]: sunxi_i2s.c
src/sys/arch/zaurus/dev [isaki-audio2]: wm8731_zaudio.c wm8750_zaudio.c
src/sys/dev [isaki-audio2]: audio_dai.h audio_if.h
src/sys/dev/audio [isaki-audio2]: audio.c
src/sys/dev/bluetooth [isaki-audio2]: btsco.c
src/sys/dev/fdt [isaki-audio2]: ausoc.c
src/sys/dev/ic [isaki-audio2]: ad1848var.h arcofi.c interwave.c
interwavevar.h
src/sys/dev/isa [isaki-audio2]: ad1848_isa.c ad1848var.h ess.c gus.c
wss.c ym.c
src/sys/dev/isapnp [isaki-audio2]: gus_isapnp.c
src/sys/dev/pci [isaki-audio2]: esa.c gcscaudio.c yds.c

Log Message:
Remove obsoleted methods in audio_hw_if.
- drain: is handled in audio upper layer now.
- mappage: is handled in audio upper layer now.
- setfd: no one uses and it's meaningless now.


To generate a diff of this commit:
cvs rdiff -u -r1.18.2.1 -r1.18.2.2 src/sys/arch/amiga/dev/toccata.c
cvs rdiff -u -r1.1.24.1 -r1.1.24.2 src/sys/arch/arm/imx/imx23_digfilt.c
cvs rdiff -u -r1.3.2.1 -r1.3.2.2 src/sys/arch/arm/sunxi/sunxi_i2s.c
cvs rdiff -u -r1.2.4.1 -r1.2.4.2 src/sys/arch/zaurus/dev/wm8731_zaudio.c
cvs rdiff -u -r1.2.4.2 -r1.2.4.3 src/sys/arch/zaurus/dev/wm8750_zaudio.c
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/sys/dev/audio_dai.h
cvs rdiff -u -r1.70.24.3 -r1.70.24.4 src/sys/dev/audio_if.h
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.38.2.2 -r1.38.2.3 src/sys/dev/bluetooth/btsco.c
cvs rdiff -u -r1.3.8.1 -r1.3.8.2 src/sys/dev/fdt/ausoc.c
cvs rdiff -u -r1.18.54.1 -r1.18.54.2 src/sys/dev/ic/ad1848var.h
cvs rdiff -u -r1.1.28.3 -r1.1.28.4 src/sys/dev/ic/arcofi.c
cvs rdiff -u -r1.40.2.1 -r1.40.2.2 src/sys/dev/ic/interwave.c
cvs rdiff -u -r1.18.42.1 -r1.18.42.2 src/sys/dev/ic/interwavevar.h
cvs rdiff -u -r1.38.54.1 -r1.38.54.2 src/sys/dev/isa/ad1848_isa.c
cvs rdiff -u -r1.44 -r1.44.54.1 src/sys/dev/isa/ad1848var.h
cvs rdiff -u -r1.84.2.2 -r1.84.2.3 src/sys/dev/isa/ess.c
cvs rdiff -u -r1.115.2.1 -r1.115.2.2 src/sys/dev/isa/gus.c
cvs rdiff -u -r1.72.2.1 -r1.72.2.2 src/sys/dev/isa/wss.c
cvs rdiff -u -r1.45.2.1 -r1.45.2.2 src/sys/dev/isa/ym.c
cvs rdiff -u -r1.39.2.3 -r1.39.2.4 src/sys/dev/isapnp/gus_isapnp.c
cvs rdiff -u -r1.63.2.2 -r1.63.2.3 src/sys/dev/pci/esa.c
cvs rdiff -u -r1.16.2.2 -r1.16.2.3 src/sys/dev/pci/gcscaudio.c
cvs rdiff -u -r1.61.2.2 -r1.61.2.3 src/sys/dev/pci/yds.c

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/amiga/dev/toccata.c
diff -u src/sys/arch/amiga/dev/toccata.c:1.18.2.1 src/sys/arch/amiga/dev/toccata.c:1.18.2.2
--- src/sys/arch/amiga/dev/toccata.c:1.18.2.1	Sun Apr 21 05:59:59 2019
+++ src/sys/arch/amiga/dev/toccata.c	Sat May  4 04:13:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: toccata.c,v 1.18.2.1 2019/04/21 05:59:59 isaki Exp $ */
+/* $NetBSD: toccata.c,v 1.18.2.2 2019/05/04 04:13:23 isaki Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: toccata.c,v 1.18.2.1 2019/04/21 05:59:59 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: toccata.c,v 1.18.2.2 2019/05/04 04:13:23 isaki Exp $");
 
 #include 
 #include 
@@ -179,12 +179,6 @@ void toccata_get_locks(void *, kmutex_t 
 const struct audio_hw_if audiocs_hw_if = {
 	.open			= toccata_open,
 	.close			= toccata_close,
-	/*
-	 * XXX toccata_drain could be written:
-	 * sleep for play interrupt. This loses less than 512 bytes of
-	 * sample data, otherwise up to 1024.
-	 */
-	.drain			= NULL,
 	.query_format		= ad1848_query_format,
 	.set_format		= ad1848_set_format,
 	.round_blocksize	= toccata_round_blocksize,

Index: src/sys/arch/arm/imx/imx23_digfilt.c
diff -u src/sys/arch/arm/imx/imx23_digfilt.c:1.1.24.1 src/sys/arch/arm/imx/imx23_digfilt.c:1.1.24.2
--- src/sys/arch/arm/imx/imx23_digfilt.c:1.1.24.1	Wed Apr 24 12:01:50 2019
+++ src/sys/arch/arm/imx/imx23_digfilt.c	Sat May  4 04:13:23 2019
@@ -1,4 +1,4 @@
-/* $Id: imx23_digfilt.c,v 1.1.24.1 2019/04/24 12:01:50 isaki Exp $ */
+/* $Id: imx23_digfilt.c,v 1.1.24.2 2019/05/04 04:13:23 isaki Exp $ */
 
 /*
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -159,14 +159,12 @@ static const struct audio_hw_if digfilt_
 	.halt_output = digfilt_halt_output,
 	.speaker_ctl = NULL,
 	.getdev = digfilt_getdev,
-	.setfd = NULL,
 	.set_port = digfilt_set_port,
 	.get_port = digfilt_get_port,
 	.query_devinfo = digfilt_query_devinfo,
 	.allocm = digfilt_allocm,
 	.freem = digfilt_freem,
 	.round_buffersize = digfilt_round_buffersize,
-	.mappage = NULL,
 	.get_props = digfilt_get_props,
 	.trigger_output = NULL,
 	.trigger_input = NULL,

Index: src/sys/arch/arm/sunxi/sunxi_i2s.c
diff -u src/sys/arch/arm/sunxi/sun

CVS commit: [isaki-audio2] src/sys/dev

2019-05-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri May  3 06:29:05 UTC 2019

Modified Files:
src/sys/dev/audio [isaki-audio2]: audio.c
Removed Files:
src/sys/dev [isaki-audio2]: audiovar.h

Log Message:
Remove dev/audiovar.h.  It already have been just a link to
dev/audio/audiovar.h in this branch.


To generate a diff of this commit:
cvs rdiff -u -r1.68.8.1 -r0 src/sys/dev/audiovar.h
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.1.2.4 src/sys/dev/audio/audio.c:1.1.2.5
--- src/sys/dev/audio/audio.c:1.1.2.4	Fri May  3 05:15:33 2019
+++ src/sys/dev/audio/audio.c	Fri May  3 06:29:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.1.2.4 2019/05/03 05:15:33 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.1.2.5 2019/05/03 06:29:05 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -152,7 +152,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.4 2019/05/03 05:15:33 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.5 2019/05/03 06:29:05 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -193,7 +193,7 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.
 #include 
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 



CVS commit: [isaki-audio2] src/sys

2019-05-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri May  3 06:19:42 UTC 2019

Modified Files:
src/sys/arch/arm/xscale [isaki-audio2]: pxa2x0_ac97.c
src/sys/dev [isaki-audio2]: spkr_audio.c
src/sys/dev/ic [isaki-audio2]: msm6258.c pl041var.h
src/sys/dev/isa [isaki-audio2]: cms.c
src/sys/dev/isapnp [isaki-audio2]: gus_isapnp.c
src/sys/dev/pci [isaki-audio2]: auvia.c emuxki.c

Log Message:
Remove unnecessary header file.


To generate a diff of this commit:
cvs rdiff -u -r1.15.2.2 -r1.15.2.3 src/sys/arch/arm/xscale/pxa2x0_ac97.c
cvs rdiff -u -r1.6 -r1.6.12.1 src/sys/dev/spkr_audio.c
cvs rdiff -u -r1.25.2.1 -r1.25.2.2 src/sys/dev/ic/msm6258.c
cvs rdiff -u -r1.1.16.1 -r1.1.16.2 src/sys/dev/ic/pl041var.h
cvs rdiff -u -r1.22 -r1.22.20.1 src/sys/dev/isa/cms.c
cvs rdiff -u -r1.39.2.2 -r1.39.2.3 src/sys/dev/isapnp/gus_isapnp.c
cvs rdiff -u -r1.82.2.2 -r1.82.2.3 src/sys/dev/pci/auvia.c
cvs rdiff -u -r1.67.2.5 -r1.67.2.6 src/sys/dev/pci/emuxki.c

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/xscale/pxa2x0_ac97.c
diff -u src/sys/arch/arm/xscale/pxa2x0_ac97.c:1.15.2.2 src/sys/arch/arm/xscale/pxa2x0_ac97.c:1.15.2.3
--- src/sys/arch/arm/xscale/pxa2x0_ac97.c:1.15.2.2	Tue Apr 23 13:38:48 2019
+++ src/sys/arch/arm/xscale/pxa2x0_ac97.c	Fri May  3 06:19:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pxa2x0_ac97.c,v 1.15.2.2 2019/04/23 13:38:48 isaki Exp $	*/
+/*	$NetBSD: pxa2x0_ac97.c,v 1.15.2.3 2019/05/03 06:19:42 isaki Exp $	*/
 
 /*
  * Copyright (c) 2003, 2005 Wasabi Systems, Inc.
@@ -48,7 +48,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 

Index: src/sys/dev/spkr_audio.c
diff -u src/sys/dev/spkr_audio.c:1.6 src/sys/dev/spkr_audio.c:1.6.12.1
--- src/sys/dev/spkr_audio.c:1.6	Sun Jun 11 21:54:22 2017
+++ src/sys/dev/spkr_audio.c	Fri May  3 06:19:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: spkr_audio.c,v 1.6 2017/06/11 21:54:22 pgoyette Exp $	*/
+/*	$NetBSD: spkr_audio.c,v 1.6.12.1 2019/05/03 06:19:42 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.6 2017/06/11 21:54:22 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.6.12.1 2019/05/03 06:19:42 isaki Exp $");
 
 #include 
 #include 
@@ -41,7 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: spkr_audio.c
 #include 
 #include 
 #include 
-#include 
 
 #include 
 

Index: src/sys/dev/ic/msm6258.c
diff -u src/sys/dev/ic/msm6258.c:1.25.2.1 src/sys/dev/ic/msm6258.c:1.25.2.2
--- src/sys/dev/ic/msm6258.c:1.25.2.1	Sun Apr 21 14:00:19 2019
+++ src/sys/dev/ic/msm6258.c	Fri May  3 06:19:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: msm6258.c,v 1.25.2.1 2019/04/21 14:00:19 isaki Exp $	*/
+/*	$NetBSD: msm6258.c,v 1.25.2.2 2019/05/03 06:19:42 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msm6258.c,v 1.25.2.1 2019/04/21 14:00:19 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msm6258.c,v 1.25.2.2 2019/05/03 06:19:42 isaki Exp $");
 
 #include 
 #include 
@@ -39,7 +39,6 @@ __KERNEL_RCSID(0, "$NetBSD: msm6258.c,v 
 #include 
 
 #include 
-#include 
 #include 
 
 static inline uint8_t	pcm2adpcm_step(struct msm6258_codecvar *, int16_t);

Index: src/sys/dev/ic/pl041var.h
diff -u src/sys/dev/ic/pl041var.h:1.1.16.1 src/sys/dev/ic/pl041var.h:1.1.16.2
--- src/sys/dev/ic/pl041var.h:1.1.16.1	Sat Apr 27 11:52:53 2019
+++ src/sys/dev/ic/pl041var.h	Fri May  3 06:19:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: pl041var.h,v 1.1.16.1 2019/04/27 11:52:53 isaki Exp $ */
+/* $NetBSD: pl041var.h,v 1.1.16.2 2019/05/03 06:19:42 isaki Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -29,7 +29,6 @@
 #ifndef _PL041VAR_H
 #define _PL041VAR_H
 
-#include 
 #include 
 
 struct aaci_softc {

Index: src/sys/dev/isa/cms.c
diff -u src/sys/dev/isa/cms.c:1.22 src/sys/dev/isa/cms.c:1.22.20.1
--- src/sys/dev/isa/cms.c:1.22	Sat Dec 10 17:41:44 2016
+++ src/sys/dev/isa/cms.c	Fri May  3 06:19:42 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cms.c,v 1.22 2016/12/10 17:41:44 maya Exp $ */
+/* $NetBSD: cms.c,v 1.22.20.1 2019/05/03 06:19:42 isaki Exp $ */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cms.c,v 1.22 2016/12/10 17:41:44 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cms.c,v 1.22.20.1 2019/05/03 06:19:42 isaki Exp $");
 
 #include 
 #include 
@@ -39,7 +39,6 @@ __KERNEL_RCSID(0, "$NetBSD: cms.c,v 1.22
 
 #include 
 #include 
-#include 
 
 #include 
 #include 

Index: src/sys/dev/isapnp/gus_isapnp.c
diff -u src/sys/dev/isapnp/gus_isapnp.c:1.39.2.2 src/sys/dev/isapnp/gus_isapnp.c:1.39.2.3
--- src/sys/dev/isapnp/gus_isapnp.c:1.39.2.2	Fri May  3 05:43:46 2019
+++ src/sys/dev/isapnp/gus_isapnp.c	Fri May  3 06:19:42 2019
@@ -1,4 +1,4 @@
-/*	$Net

CVS commit: [isaki-audio2] src/sys

2019-05-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri May  3 05:43:47 UTC 2019

Modified Files:
src/sys/arch/arm/sunxi [isaki-audio2]: sunxi_codec.h
src/sys/arch/i386/pnpbios [isaki-audio2]: ess_pnpbios.c sb_pnpbios.c
ym_pnpbios.c
src/sys/dev [isaki-audio2]: files.audio
src/sys/dev/hdaudio [isaki-audio2]: hdaudiovar.h
src/sys/dev/isa [isaki-audio2]: ad1848_isa.c sb_isa.c
src/sys/dev/isapnp [isaki-audio2]: ess_isapnp.c gus_isapnp.c
mpu_isapnp.c sb_isapnp.c
src/sys/dev/ofisa [isaki-audio2]: ess_ofisa.c sb_ofisa.c
src/sys/dev/pci [isaki-audio2]: cs428x.c
src/sys/dev/usb [isaki-audio2]: umidi.c umidi_quirks.c
Removed Files:
src/sys/dev [isaki-audio2]: auconv.c auconv.h mulaw.h

Log Message:
Remove dev/auconv.[ch].
 Now it is handled in dev/audio/audio.c and dev/audio/linear.c.
Remove dev/mulaw.h.
 It already have been just a link to dev/audio/mulaw.h in this
 branch.


To generate a diff of this commit:
cvs rdiff -u -r1.4.8.1 -r1.4.8.2 src/sys/arch/arm/sunxi/sunxi_codec.h
cvs rdiff -u -r1.22 -r1.22.56.1 src/sys/arch/i386/pnpbios/ess_pnpbios.c
cvs rdiff -u -r1.17 -r1.17.20.1 src/sys/arch/i386/pnpbios/sb_pnpbios.c
cvs rdiff -u -r1.18 -r1.18.20.1 src/sys/arch/i386/pnpbios/ym_pnpbios.c
cvs rdiff -u -r1.37.2.1 -r0 src/sys/dev/auconv.c
cvs rdiff -u -r1.21.8.1 -r0 src/sys/dev/auconv.h
cvs rdiff -u -r1.11.16.1 -r1.11.16.2 src/sys/dev/files.audio
cvs rdiff -u -r1.25.8.1 -r0 src/sys/dev/mulaw.h
cvs rdiff -u -r1.6 -r1.6.6.1 src/sys/dev/hdaudio/hdaudiovar.h
cvs rdiff -u -r1.38 -r1.38.54.1 src/sys/dev/isa/ad1848_isa.c \
src/sys/dev/isa/sb_isa.c
cvs rdiff -u -r1.22 -r1.22.64.1 src/sys/dev/isapnp/ess_isapnp.c
cvs rdiff -u -r1.39.2.1 -r1.39.2.2 src/sys/dev/isapnp/gus_isapnp.c
cvs rdiff -u -r1.20 -r1.20.52.1 src/sys/dev/isapnp/mpu_isapnp.c
cvs rdiff -u -r1.52 -r1.52.96.1 src/sys/dev/isapnp/sb_isapnp.c
cvs rdiff -u -r1.27 -r1.27.20.1 src/sys/dev/ofisa/ess_ofisa.c
cvs rdiff -u -r1.18 -r1.18.20.1 src/sys/dev/ofisa/sb_ofisa.c
cvs rdiff -u -r1.18.14.1 -r1.18.14.2 src/sys/dev/pci/cs428x.c
cvs rdiff -u -r1.76 -r1.76.2.1 src/sys/dev/usb/umidi.c
cvs rdiff -u -r1.21 -r1.21.20.1 src/sys/dev/usb/umidi_quirks.c

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/sunxi/sunxi_codec.h
diff -u src/sys/arch/arm/sunxi/sunxi_codec.h:1.4.8.1 src/sys/arch/arm/sunxi/sunxi_codec.h:1.4.8.2
--- src/sys/arch/arm/sunxi/sunxi_codec.h:1.4.8.1	Sat Apr 27 05:30:37 2019
+++ src/sys/arch/arm/sunxi/sunxi_codec.h	Fri May  3 05:43:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_codec.h,v 1.4.8.1 2019/04/27 05:30:37 isaki Exp $ */
+/* $NetBSD: sunxi_codec.h,v 1.4.8.2 2019/05/03 05:43:46 isaki Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -31,7 +31,6 @@
 
 #include 
 #include 
-#include 
 
 #include 
 

Index: src/sys/arch/i386/pnpbios/ess_pnpbios.c
diff -u src/sys/arch/i386/pnpbios/ess_pnpbios.c:1.22 src/sys/arch/i386/pnpbios/ess_pnpbios.c:1.22.56.1
--- src/sys/arch/i386/pnpbios/ess_pnpbios.c:1.22	Fri Jul  1 18:14:15 2011
+++ src/sys/arch/i386/pnpbios/ess_pnpbios.c	Fri May  3 05:43:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ess_pnpbios.c,v 1.22 2011/07/01 18:14:15 dyoung Exp $	*/
+/*	$NetBSD: ess_pnpbios.c,v 1.22.56.1 2019/05/03 05:43:46 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ess_pnpbios.c,v 1.22 2011/07/01 18:14:15 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ess_pnpbios.c,v 1.22.56.1 2019/05/03 05:43:46 isaki Exp $");
 
 #include 
 #include 
@@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: ess_pnpbios.
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 

Index: src/sys/arch/i386/pnpbios/sb_pnpbios.c
diff -u src/sys/arch/i386/pnpbios/sb_pnpbios.c:1.17 src/sys/arch/i386/pnpbios/sb_pnpbios.c:1.17.20.1
--- src/sys/arch/i386/pnpbios/sb_pnpbios.c:1.17	Mon Jul 11 11:31:49 2016
+++ src/sys/arch/i386/pnpbios/sb_pnpbios.c	Fri May  3 05:43:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sb_pnpbios.c,v 1.17 2016/07/11 11:31:49 msaitoh Exp $ */
+/* $NetBSD: sb_pnpbios.c,v 1.17.20.1 2019/05/03 05:43:46 isaki Exp $ */
 /*
  * Copyright (c) 1999
  * 	Matthias Drochner.  All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sb_pnpbios.c,v 1.17 2016/07/11 11:31:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sb_pnpbios.c,v 1.17.20.1 2019/05/03 05:43:46 isaki Exp $");
 
 #include 
 #include 
@@ -41,7 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: sb_pnpbios.c
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 

Index: src/sys/arch/i386/pnpbios/ym_pnpbios.c
diff -u src/sys/arch/i386/pnpbios/ym_pnpbios.c:1.18 src/sys/arch/i386/pnpbios/ym_pnpbios.c:1.18.20.1
--- src/sys/arch/i386/pnpbios/ym_pnpbios.c:1.18	Thu Jul 14 10:19:05 2016
+++ src/sys/arch/i386/pnpbios/ym_pnpbios.c	Fri May  3 05:43:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ym

CVS commit: [isaki-audio2] src/sys/dev

2019-05-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri May  3 05:15:33 UTC 2019

Modified Files:
src/sys/dev [isaki-audio2]: audio_if.h
src/sys/dev/audio [isaki-audio2]: audio.c

Log Message:
Remove query_encoding and set_params interfaces from audio_hw_if
and remove related backward compatible routines.
All drivers were converted to use new query_format/set_format.


To generate a diff of this commit:
cvs rdiff -u -r1.70.24.2 -r1.70.24.3 src/sys/dev/audio_if.h
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio_if.h
diff -u src/sys/dev/audio_if.h:1.70.24.2 src/sys/dev/audio_if.h:1.70.24.3
--- src/sys/dev/audio_if.h:1.70.24.2	Sat Apr 27 12:05:28 2019
+++ src/sys/dev/audio_if.h	Fri May  3 05:15:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio_if.h,v 1.70.24.2 2019/04/27 12:05:28 isaki Exp $	*/
+/*	$NetBSD: audio_if.h,v 1.70.24.3 2019/05/03 05:15:33 isaki Exp $	*/
 
 /*
  * Copyright (c) 1994 Havard Eidnes.
@@ -182,20 +182,10 @@ struct audio_hw_if {
 	/* Obsoleted in AUDIO2. */
 	int	(*drain)(void *);	/* Optional: drain buffers */
 
-	/* Encoding. */
-	/* Obsoleted in AUDIO2. */
-	int	(*query_encoding)(void *, audio_encoding_t *);
-
-	/* Set the audio encoding parameters (record and play).
-	 * Return 0 on success, or an error code if the
-	 * requested parameters are impossible.
-	 * The values in the params struct may be changed (e.g. rounding
-	 * to the nearest sample rate.)
-	 */
-	/* Obsoleted in AUDIO2. */
-	int	(*set_params)(void *, int, int, audio_params_t *,
-		audio_params_t *, stream_filter_list_t *,
-		stream_filter_list_t *);
+	int	(*query_format)(void *, audio_format_query_t *);
+	int	(*set_format)(void *, int,
+		const audio_params_t *, const audio_params_t *,
+		audio_filter_reg_t *, audio_filter_reg_t *);
 
 	/* Hardware may have some say in the blocksize to choose */
 	int	(*round_blocksize)(void *, int, int, const audio_params_t *);
@@ -252,10 +242,6 @@ struct audio_hw_if {
 	int	(*dev_ioctl)(void *, u_long, void *, int, struct lwp *);
 	void	(*get_locks)(void *, kmutex_t **, kmutex_t **);
 
-	int	(*query_format)(void *, audio_format_query_t *);
-	int	(*set_format)(void *, int,
-		const audio_params_t *, const audio_params_t *,
-		audio_filter_reg_t *, audio_filter_reg_t *);
 };
 
 struct audio_attach_args {

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.1.2.3 src/sys/dev/audio/audio.c:1.1.2.4
--- src/sys/dev/audio/audio.c:1.1.2.3	Sat Apr 27 12:05:28 2019
+++ src/sys/dev/audio/audio.c	Fri May  3 05:15:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.1.2.3 2019/04/27 12:05:28 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.1.2.4 2019/05/03 05:15:33 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -104,8 +104,8 @@
  *	open 			x	x +
  *	close 			x	x +
  *	drain 			x	x	(Not used in AUDIO2)
- *	query_encoding		-	x	(Not used in AUDIO2)
- *	set_params 		-	x	(Obsoleted in AUDIO2)
+ *	query_format		-	x
+ *	set_format		-	x
  *	round_blocksize		-	x
  *	commit_settings		-	x
  *	init_output 		x	x
@@ -129,8 +129,6 @@
  *	trigger_input 		x	x +
  *	dev_ioctl 		-	x
  *	get_locks 		-	-	Called at attach time
- *	query_format		-	x	(Added in AUDIO2)
- *	set_format		-	x	(Added in AUDIO2)
  *
  * *1 Note: Before 8.0, since these have been called only at attach time,
  *   neither lock were necessary.  In AUDIO2, on the other hand, since
@@ -154,7 +152,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.3 2019/04/27 12:05:28 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.1.2.4 2019/05/03 05:15:33 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -164,7 +162,6 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.
 #if NAUDIO > 0
 
 #ifdef _KERNEL
-#define OLD_FILTER
 
 #include 
 #include 
@@ -197,7 +194,6 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -211,7 +207,7 @@ __KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.
 
 /*
  * 0: No debug logs
- * 1: action changes like open/close/set_param...
+ * 1: action changes like open/close/set_format...
  * 2: + normal operations like read/write/ioctl...
  * 3: + TRACEs except interrupt
  * 4: + TRACEs including interrupt
@@ -485,15 +481,6 @@ struct portname {
 	int mask;
 };
 
-#if defined(OLD_FILTER)
-typedef struct uio_fetcher {
-	stream_fetcher_t base;
-	struct uio *uio;
-	int usedhigh;
-	int last_used;
-} uio_fetcher_t;
-#endif
-
 static int audiomatch(device_t, cfdata_t, void *);
 static void audioattach(device_t, device_t, void *);
 static int audiodetach(device_t, int);
@@ -570,7 +557,7 @@ static void audio_track_setinfo_water(au
 	const struct audio_info *);
 static int audio_hw_setinfo(struct audio_softc *, const struct audio_info *,
 	struct audio_info *);
-static int audio_hw_set_params(struct audio_softc *, int,
+static int audio_hw_se

CVS commit: [isaki-audio2] src/sys/arch/dreamcast/dev/g2

2019-05-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri May  3 04:15:23 UTC 2019

Modified Files:
src/sys/arch/dreamcast/dev/g2 [isaki-audio2]: aica.c

Log Message:
Adapt to audio2.
- audio2 limits the lowest frequency.
- Remove unused sc_encodings.
- In audio2, round_buffersize(RECORD) will not be called if the
  driver does not support recording.


To generate a diff of this commit:
cvs rdiff -u -r1.25.2.1 -r1.25.2.2 src/sys/arch/dreamcast/dev/g2/aica.c

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/dreamcast/dev/g2/aica.c
diff -u src/sys/arch/dreamcast/dev/g2/aica.c:1.25.2.1 src/sys/arch/dreamcast/dev/g2/aica.c:1.25.2.2
--- src/sys/arch/dreamcast/dev/g2/aica.c:1.25.2.1	Sun Apr 21 05:11:21 2019
+++ src/sys/arch/dreamcast/dev/g2/aica.c	Fri May  3 04:15:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: aica.c,v 1.25.2.1 2019/04/21 05:11:21 isaki Exp $	*/
+/*	$NetBSD: aica.c,v 1.25.2.2 2019/05/03 04:15:23 isaki Exp $	*/
 
 /*
  * Copyright (c) 2003 SHIMIZU Ryo 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: aica.c,v 1.25.2.1 2019/04/21 05:11:21 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aica.c,v 1.25.2.2 2019/05/03 04:15:23 isaki Exp $");
 
 #include 
 #include 
@@ -40,8 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: aica.c,v 1.2
 #include 
 
 #include 
-#include 
-#include 
+#include 	/* AUDIO_MIN_FREQUENCY */
 
 #include 
 
@@ -65,7 +64,6 @@ struct aica_softc {
 
 	/* audio property */
 	int			sc_open;
-	int			sc_encodings;
 	int			sc_precision;
 	int			sc_channels;
 	int			sc_rate;
@@ -85,41 +83,19 @@ struct aica_softc {
 	int			sc_nextfill;
 };
 
-const struct {
-	const char *name;
-	int	encoding;
-	int	precision;
-} aica_encodings[] = {
-	{AudioEadpcm,		AUDIO_ENCODING_ADPCM,		4},
-	{AudioEslinear,		AUDIO_ENCODING_SLINEAR,		8},
-	{AudioEulinear,		AUDIO_ENCODING_ULINEAR,		8},
-	{AudioEmulaw,		AUDIO_ENCODING_ULAW,		8},
-	{AudioEalaw,		AUDIO_ENCODING_ALAW,		8},
-	{AudioEslinear_be,	AUDIO_ENCODING_SLINEAR_BE,	16},
-	{AudioEslinear_le,	AUDIO_ENCODING_SLINEAR_LE,	16},
-	{AudioEulinear_be,	AUDIO_ENCODING_ULINEAR_BE,	16},
-	{AudioEulinear_le,	AUDIO_ENCODING_ULINEAR_LE,	16},
-};
-
-#define AICA_NFORMATS	5
-#define AICA_FORMAT(enc, prec, ch, chmask) \
-	{ \
-		.mode		= AUMODE_PLAY, \
-		.encoding	= (enc), \
-		.validbits	= (prec), \
-		.precision	= (prec), \
-		.channels	= (ch), \
-		.channel_mask	= (chmask), \
-		.frequency_type	= 0, \
-		.frequency	= { 1, 65536 }, \
-	}
-static const struct audio_format aica_formats[AICA_NFORMATS] = {
-	AICA_FORMAT(AUDIO_ENCODING_ADPCM,   4, 1, AUFMT_MONAURAL),
-	AICA_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	AICA_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	AICA_FORMAT(AUDIO_ENCODING_SLINEAR_LE,  8, 1, AUFMT_MONAURAL),
-	AICA_FORMAT(AUDIO_ENCODING_SLINEAR_LE,  8, 2, AUFMT_STEREO),
+static const struct audio_format aica_formats[] = {
+	{
+		.mode		= AUMODE_PLAY,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 0,
+		.frequency	= { AUDIO_MIN_FREQUENCY, 65536 },
+	},
 };
+#define AICA_NFORMATS	__arraycount(aica_formats)
 
 int aica_match(device_t, cfdata_t, void *);
 void aica_attach(device_t, device_t, void *);
@@ -151,9 +127,10 @@ int aica_intr(void *);
 /* for audio */
 int aica_open(void *, int);
 void aica_close(void *);
-int aica_query_encoding(void *, struct audio_encoding *);
-int aica_set_params(void *, int, int, audio_params_t *,
-audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+int aica_query_format(void *, audio_format_query_t *);
+int aica_set_format(void *, int,
+const audio_params_t *, const audio_params_t *,
+audio_filter_reg_t *, audio_filter_reg_t *);
 int aica_round_blocksize(void *, int, int, const audio_params_t *);
 size_t aica_round_buffersize(void *, int, size_t);
 int aica_trigger_output(void *, void *, void *, int, void (*)(void *), void *,
@@ -173,8 +150,8 @@ void aica_get_locks(void *, kmutex_t **,
 const struct audio_hw_if aica_hw_if = {
 	.open			= aica_open,
 	.close			= aica_close,
-	.query_encoding		= aica_query_encoding,
-	.set_params		= aica_set_params,
+	.query_format		= aica_query_format,
+	.set_format		= aica_set_format,
 	.round_blocksize	= aica_round_blocksize,
 	.halt_output		= aica_halt_output,
 	.halt_input		= aica_halt_input,
@@ -442,38 +419,23 @@ aica_close(void *addr)
 }
 
 int
-aica_query_encoding(void *addr, struct audio_encoding *fp)
+aica_query_format(void *addr, audio_format_query_t *afp)
 {
-	if (fp->index >= sizeof(aica_encodings) / sizeof(aica_encodings[0]))
-		return EINVAL;
 
-	strcpy(fp->name, aica_encodings[fp->index].name);
-	fp->encoding = aica_encodings[fp->index].encoding;
-	fp->precision = aica_encodings[fp->index].precision;
-	fp->flags = 0;
-
-	return 0;
+	return audio_query_format(aica_formats, AICA_NFORMATS, afp);
 }
 
 int
-aica_set_p

CVS commit: [isaki-audio2] src/sys/dev/isa

2019-05-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri May  3 03:00:33 UTC 2019

Modified Files:
src/sys/dev/isa [isaki-audio2]: pas.c sb.c sbdsp.c sbdspvar.h

Log Message:
Adapt sbdsp to audio2.
- Use new query_format/set_format interfaces.
  The formats are created from sb[pr]modes tables.
- Drop INDEPENDENT property for models proir to SB_16.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.71.2.1 src/sys/dev/isa/pas.c
cvs rdiff -u -r1.90 -r1.90.2.1 src/sys/dev/isa/sb.c
cvs rdiff -u -r1.139.2.1 -r1.139.2.2 src/sys/dev/isa/sbdsp.c
cvs rdiff -u -r1.61 -r1.61.54.1 src/sys/dev/isa/sbdspvar.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/dev/isa/pas.c
diff -u src/sys/dev/isa/pas.c:1.71 src/sys/dev/isa/pas.c:1.71.2.1
--- src/sys/dev/isa/pas.c:1.71	Sat Mar 16 12:09:58 2019
+++ src/sys/dev/isa/pas.c	Fri May  3 03:00:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pas.c,v 1.71 2019/03/16 12:09:58 isaki Exp $	*/
+/*	$NetBSD: pas.c,v 1.71.2.1 2019/05/03 03:00:33 isaki Exp $	*/
 
 /*
  * Copyright (c) 1991-1993 Regents of the University of California.
@@ -57,7 +57,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pas.c,v 1.71 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pas.c,v 1.71.2.1 2019/05/03 03:00:33 isaki Exp $");
 
 #include 
 #include 
@@ -125,8 +125,8 @@ void	pasconf(int, int, int, int);
 const struct audio_hw_if pas_hw_if = {
 	.open			= sbdsp_open,
 	.close			= sbdsp_close,
-	.query_encoding		= sbdsp_query_encoding,
-	.set_params		= sbdsp_set_params,
+	.query_format		= sbdsp_query_format,
+	.set_format		= sbdsp_set_format,
 	.round_blocksize	= sbdsp_round_blocksize,
 	.halt_output		= sbdsp_halt_output,
 	.halt_input		= sbdsp_halt_input,
@@ -138,7 +138,6 @@ const struct audio_hw_if pas_hw_if = {
 	.allocm			= sb_malloc,
 	.freem			= sb_free,
 	.round_buffersize	= sb_round_buffersize,
-	.mappage		= sb_mappage,
 	.get_props		= sbdsp_get_props,
 	.trigger_output		= sbdsp_trigger_output,
 	.trigger_input		= sbdsp_trigger_input,

Index: src/sys/dev/isa/sb.c
diff -u src/sys/dev/isa/sb.c:1.90 src/sys/dev/isa/sb.c:1.90.2.1
--- src/sys/dev/isa/sb.c:1.90	Sat Mar 16 12:09:58 2019
+++ src/sys/dev/isa/sb.c	Fri May  3 03:00:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sb.c,v 1.90 2019/03/16 12:09:58 isaki Exp $	*/
+/*	$NetBSD: sb.c,v 1.90.2.1 2019/05/03 03:00:33 isaki Exp $	*/
 
 /*
  * Copyright (c) 1991-1993 Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sb.c,v 1.90 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sb.c,v 1.90.2.1 2019/05/03 03:00:33 isaki Exp $");
 
 #include "midi.h"
 
@@ -82,8 +82,8 @@ int	sb_getdev(void *, struct audio_devic
 const struct audio_hw_if sb_hw_if = {
 	.open			= sbdsp_open,
 	.close			= sbdsp_close,
-	.query_encoding		= sbdsp_query_encoding,
-	.set_params		= sbdsp_set_params,
+	.query_format		= sbdsp_query_format,
+	.set_format		= sbdsp_set_format,
 	.round_blocksize	= sbdsp_round_blocksize,
 	.halt_output		= sbdsp_halt_output,
 	.halt_input		= sbdsp_halt_input,
@@ -95,7 +95,6 @@ const struct audio_hw_if sb_hw_if = {
 	.allocm			= sb_malloc,
 	.freem			= sb_free,
 	.round_buffersize	= sb_round_buffersize,
-	.mappage		= sb_mappage,
 	.get_props		= sbdsp_get_props,
 	.trigger_output		= sbdsp_trigger_output,
 	.trigger_input		= sbdsp_trigger_input,

Index: src/sys/dev/isa/sbdsp.c
diff -u src/sys/dev/isa/sbdsp.c:1.139.2.1 src/sys/dev/isa/sbdsp.c:1.139.2.2
--- src/sys/dev/isa/sbdsp.c:1.139.2.1	Sun Apr 21 06:17:02 2019
+++ src/sys/dev/isa/sbdsp.c	Fri May  3 03:00:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbdsp.c,v 1.139.2.1 2019/04/21 06:17:02 isaki Exp $	*/
+/*	$NetBSD: sbdsp.c,v 1.139.2.2 2019/05/03 03:00:33 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sbdsp.c,v 1.139.2.1 2019/04/21 06:17:02 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbdsp.c,v 1.139.2.2 2019/05/03 03:00:33 isaki Exp $");
 
 #include "midi.h"
 #include "mpu.h"
@@ -95,6 +95,7 @@ __KERNEL_RCSID(0, "$NetBSD: sbdsp.c,v 1.
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -206,8 +207,34 @@ static struct sbmode sbrmodes[] = {
  { .model = -1 }
 };
 
+/*
+ * We actually can specify any value within the frequency range defined
+ * above.  But according to definition of SB_RATE_TO_TC macro, only some
+ * of them are dividable (it's preferable, not mandatory).  There are 9
+ * values in the range that satisfy this condition but it's too much.
+ */
+static const int sbdsp_rates[] = {
+	4000,
+	/* 5000, */
+	/* 6250, */
+	/* 1, */
+	12500,
+	/* 15625, */
+	2,
+	/* 25000, */
+	31250,
+};
+
 void	sbversion(struct sbdsp_softc *);
 void	sbdsp_jazz16_probe(struct sbdsp_softc *);
+void	sbdsp_sbmode2format(struct audio_format *, const struct sbmode *, int);
+int	sbdsp_set_format16(struct sbdsp_softc *, int,
+	const audio_params_

CVS commit: [isaki-audio2] src/sys

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 13:45:52 UTC 2019

Modified Files:
src/sys/arch/evbarm/mini2440 [isaki-audio2]: audio_mini2440.c
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
set_params -> set_format in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.1 -r1.2.2.2 \
src/sys/arch/evbarm/mini2440/audio_mini2440.c
cvs rdiff -u -r1.158.2.2 -r1.158.2.3 src/sys/dev/usb/uaudio.c

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/evbarm/mini2440/audio_mini2440.c
diff -u src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.1 src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.2
--- src/sys/arch/evbarm/mini2440/audio_mini2440.c:1.2.2.1	Thu Apr 25 13:49:39 2019
+++ src/sys/arch/evbarm/mini2440/audio_mini2440.c	Wed May  1 13:45:52 2019
@@ -285,7 +285,7 @@ uda_ssio_set_format(void *handle, int se
 	s3c2440_i2s_set_sample_width(sc->sc_i2s_handle, 16);
 
 	/* It is vital that sc_system_clock is set PRIOR to calling
-	   uda1341_set_params. */
+	   uda1341_set_format. */
 	switch (s3c2440_i2s_get_master_clock(sc->sc_i2s_handle)) {
 	case 384:
 		uc->sc_system_clock = UDA1341_CLOCK_384;

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.158.2.2 src/sys/dev/usb/uaudio.c:1.158.2.3
--- src/sys/dev/usb/uaudio.c:1.158.2.2	Wed May  1 13:09:33 2019
+++ src/sys/dev/usb/uaudio.c	Wed May  1 13:45:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.158.2.2 2019/05/01 13:09:33 isaki Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.158.2.3 2019/05/01 13:45:52 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.2 2019/05/01 13:09:33 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.3 2019/05/01 13:45:52 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2240,7 +2240,7 @@ uaudio_round_blocksize(void *addr, int b
 	} else {
 		/*
 		 * use wMaxPacketSize in bytes_per_frame.
-		 * See uaudio_set_params() and uaudio_chan_init()
+		 * See uaudio_set_format() and uaudio_chan_init()
 		 */
 		b = sc->sc_recchan.bytes_per_frame
 		* UAUDIO_NFRAMES * UAUDIO_NCHANBUFS;



CVS commit: [isaki-audio2] src/sys/dev/usb

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 13:09:34 UTC 2019

Modified Files:
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
Don't release sc_lock and sc_intr_lock in trigger_{input,output}.
In the past, sc_lock was IPL_SCHED and (probably) it had conflicted
with usb subroutines.  But at some point, sc_lock has changed to use
IPL_SOFTUSB so such problems should been gone.


To generate a diff of this commit:
cvs rdiff -u -r1.158.2.1 -r1.158.2.2 src/sys/dev/usb/uaudio.c

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

Modified files:

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.158.2.1 src/sys/dev/usb/uaudio.c:1.158.2.2
--- src/sys/dev/usb/uaudio.c:1.158.2.1	Wed May  1 12:42:14 2019
+++ src/sys/dev/usb/uaudio.c	Wed May  1 13:09:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.158.2.1 2019/05/01 12:42:14 isaki Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.158.2.2 2019/05/01 13:09:33 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.1 2019/05/01 12:42:14 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.2 2019/05/01 13:09:33 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2535,20 +2535,14 @@ uaudio_trigger_input(void *addr, void *s
 		"fraction=0.%03d\n", ch->sample_size, ch->bytes_per_frame,
 		ch->fraction);
 
-	mutex_exit(&sc->sc_intr_lock);
-	mutex_exit(&sc->sc_lock);
 	err = uaudio_chan_open(sc, ch);
 	if (err) {
-		mutex_enter(&sc->sc_lock);
-		mutex_enter(&sc->sc_intr_lock);
 		return EIO;
 	}
 
 	err = uaudio_chan_alloc_buffers(sc, ch);
 	if (err) {
 		uaudio_chan_close(sc, ch);
-		mutex_enter(&sc->sc_lock);
-		mutex_enter(&sc->sc_intr_lock);
 		return EIO;
 	}
 
@@ -2564,9 +2558,6 @@ uaudio_trigger_input(void *addr, void *s
 		uaudio_chan_rtransfer(ch);
 	}
 
-	mutex_enter(&sc->sc_lock);
-	mutex_enter(&sc->sc_intr_lock);
-
 	return 0;
 }
 
@@ -2592,20 +2583,14 @@ uaudio_trigger_output(void *addr, void *
 		"fraction=0.%03d\n", ch->sample_size, ch->bytes_per_frame,
 		ch->fraction);
 
-	mutex_exit(&sc->sc_intr_lock);
-	mutex_exit(&sc->sc_lock);
 	err = uaudio_chan_open(sc, ch);
 	if (err) {
-		mutex_enter(&sc->sc_lock);
-		mutex_enter(&sc->sc_intr_lock);
 		return EIO;
 	}
 
 	err = uaudio_chan_alloc_buffers(sc, ch);
 	if (err) {
 		uaudio_chan_close(sc, ch);
-		mutex_enter(&sc->sc_lock);
-		mutex_enter(&sc->sc_intr_lock);
 		return EIO;
 	}
 
@@ -2614,8 +2599,6 @@ uaudio_trigger_output(void *addr, void *
 
 	for (i = 0; i < UAUDIO_NCHANBUFS; i++)
 		uaudio_chan_ptransfer(ch);
-	mutex_enter(&sc->sc_lock);
-	mutex_enter(&sc->sc_intr_lock);
 
 	return 0;
 }



CVS commit: [isaki-audio2] src/sys/dev/usb

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 12:42:14 UTC 2019

Modified Files:
src/sys/dev/usb [isaki-audio2]: uaudio.c

Log Message:
Adapt to audio2.
- Remove obsoleted or empty methods.
- Remove AUFMT_VALIDATE()/INVALIDATE().  At first, this flag is
  set/cleared but no one in the driver seems to refer at least now.
  And second, don't use such flag for other purpose.  If you need
  to do such thing, use .driver_data instead.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.158.2.1 src/sys/dev/usb/uaudio.c

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

Modified files:

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.158 src/sys/dev/usb/uaudio.c:1.158.2.1
--- src/sys/dev/usb/uaudio.c:1.158	Sat Mar 16 12:09:58 2019
+++ src/sys/dev/usb/uaudio.c	Wed May  1 12:42:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.158 2019/03/16 12:09:58 isaki Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.158.2.1 2019/05/01 12:42:14 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.158.2.1 2019/05/01 12:42:14 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -62,9 +62,6 @@ __KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1
 
 #include 
 #include 
-#include 
-#include 
-#include 
 
 #include 
 #include 
@@ -207,7 +204,6 @@ struct uaudio_softc {
 	device_t	sc_audiodev;
 	struct audio_format *sc_formats;
 	int		sc_nformats;
-	struct audio_encoding_set *sc_encodings;
 	u_int		sc_channel_config;
 	char		sc_dying;
 	struct audio_device sc_adev;
@@ -334,12 +330,10 @@ Static void	uaudio_chan_rintr
 	(struct usbd_xfer *, void *, usbd_status);
 
 Static int	uaudio_open(void *, int);
-Static void	uaudio_close(void *);
-Static int	uaudio_drain(void *);
-Static int	uaudio_query_encoding(void *, struct audio_encoding *);
-Static int	uaudio_set_params
-	(void *, int, int, struct audio_params *, struct audio_params *,
-	 stream_filter_list_t *, stream_filter_list_t *);
+Static int	uaudio_query_format(void *, audio_format_query_t *);
+Static int	uaudio_set_format
+ (void *, int, const audio_params_t *, const audio_params_t *,
+	 audio_filter_reg_t *, audio_filter_reg_t *);
 Static int	uaudio_round_blocksize(void *, int, int, const audio_params_t *);
 Static int	uaudio_trigger_output
 	(void *, void *, void *, int, void (*)(void *), void *,
@@ -358,10 +352,8 @@ Static void	uaudio_get_locks(void *, kmu
 
 Static const struct audio_hw_if uaudio_hw_if = {
 	.open			= uaudio_open,
-	.close			= uaudio_close,
-	.drain			= uaudio_drain,
-	.query_encoding		= uaudio_query_encoding,
-	.set_params		= uaudio_set_params,
+	.query_format		= uaudio_query_format,
+	.set_format		= uaudio_set_format,
 	.round_blocksize	= uaudio_round_blocksize,
 	.halt_output		= uaudio_halt_out_dma,
 	.halt_input		= uaudio_halt_in_dma,
@@ -540,7 +532,6 @@ uaudio_detach(device_t self, int flags)
 	if (sc->sc_formats != NULL)
 		kmem_free(sc->sc_formats,
 		sizeof(struct audio_format) * sc->sc_nformats);
-	auconv_delete_encodings(sc->sc_encodings);
 
 	mutex_destroy(&sc->sc_lock);
 	mutex_destroy(&sc->sc_intr_lock);
@@ -549,20 +540,12 @@ uaudio_detach(device_t self, int flags)
 }
 
 Static int
-uaudio_query_encoding(void *addr, struct audio_encoding *fp)
+uaudio_query_format(void *addr, audio_format_query_t *afp)
 {
 	struct uaudio_softc *sc;
-	int flags;
 
 	sc = addr;
-	flags = sc->sc_altflags;
-	if (sc->sc_dying)
-		return EIO;
-
-	if (sc->sc_nalts == 0 || flags == 0)
-		return ENXIO;
-
-	return auconv_query_encoding(sc->sc_encodings, fp);
+	return audio_query_format(sc->sc_formats, sc->sc_nformats, afp);
 }
 
 Static const usb_interface_descriptor_t *
@@ -1848,14 +1831,6 @@ uaudio_identify_as(struct uaudio_softc *
 		sc->sc_alts[i].aformat = auf;
 	}
 
-	if (0 != auconv_create_encodings(sc->sc_formats, sc->sc_nformats,
-	 &sc->sc_encodings)) {
-		kmem_free(sc->sc_formats,
-		sizeof(struct audio_format) * sc->sc_nformats);
-		sc->sc_formats = NULL;
-		return ENOMEM;
-	}
-
 	return USBD_NORMAL_COMPLETION;
 }
 
@@ -2185,27 +2160,6 @@ uaudio_open(void *addr, int flags)
 	return 0;
 }
 
-/*
- * Close function is called at splaudio().
- */
-Static void
-uaudio_close(void *addr)
-{
-}
-
-Static int
-uaudio_drain(void *addr)
-{
-	struct uaudio_softc *sc = addr;
-
-	KASSERT(mutex_owned(&sc->sc_intr_lock));
-
-	kpause("uaudiodr", false,
-	mstohz(UAUDIO_NCHANBUFS * UAUDIO_NFRAMES), &sc->sc_intr_lock);
-
-	return 0;
-}
-
 Static int
 uaudio_halt_out_dma(void *addr)
 {
@@ -2718,7 +2672,6 @@ uaudio_chan_abort(struct uaudio_softc *s
 
 	as = &sc->sc_alts[ch->altidx];
 	as->sc_busy = 0;
-	AUFMT_VALIDATE(as->aformat);
 	if (sc->sc_nullalt >= 0) {
 		DPRINTF("set null alt=%d\n", sc->sc_nullalt);
 		usbd_set_interface(as->ifaceh, sc->sc_nullalt);
@@ -3021,15 +2974,12 @@ uau

CVS commit: [isaki-audio2] src/sys

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 12:18:59 UTC 2019

Modified Files:
src/sys/arch/sparc/conf [isaki-audio2]: GENERIC TADPOLE3GX
src/sys/dev/sbus [isaki-audio2]: dbri.c dbrivar.h files.sbus

Log Message:
Adapt dbri to audio2.
- Add some mutex_enter/exit.
- Remove DBRI_BIG_BUFFER option.  Such big buffer will not necessary
  in audio2.
Thank you, macallan@.


To generate a diff of this commit:
cvs rdiff -u -r1.265 -r1.265.2.1 src/sys/arch/sparc/conf/GENERIC
cvs rdiff -u -r1.77 -r1.77.2.1 src/sys/arch/sparc/conf/TADPOLE3GX
cvs rdiff -u -r1.39.2.1 -r1.39.2.2 src/sys/dev/sbus/dbri.c
cvs rdiff -u -r1.15 -r1.15.8.1 src/sys/dev/sbus/dbrivar.h
cvs rdiff -u -r1.43 -r1.43.2.1 src/sys/dev/sbus/files.sbus

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/sparc/conf/GENERIC
diff -u src/sys/arch/sparc/conf/GENERIC:1.265 src/sys/arch/sparc/conf/GENERIC:1.265.2.1
--- src/sys/arch/sparc/conf/GENERIC:1.265	Sat Apr 13 08:23:00 2019
+++ src/sys/arch/sparc/conf/GENERIC	Wed May  1 12:18:59 2019
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.265 2019/04/13 08:23:00 isaki Exp $
+# $NetBSD: GENERIC,v 1.265.2.1 2019/05/01 12:18:59 isaki Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include 	"arch/sparc/conf/std.sparc"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.265 $"
+#ident 		"GENERIC-$Revision: 1.265.2.1 $"
 
 maxusers	32
 
@@ -609,7 +609,6 @@ audioamd0	at sbus0 slot ? offset ?		# su
 audiocs0	at sbus0 slot ? offset ?		# SUNW,CS4231
 
 #options 	DBRI_DEBUG	# noisy debug output from the dbri driver
-#options 	DBRI_BIG_BUFFER	# use bigger DMA buffers, for slow CPUs
 dbri*		at sbus? slot ? offset ?		# SUNW,DBRI[s3|e]
 
 audio*		at audiobus?

Index: src/sys/arch/sparc/conf/TADPOLE3GX
diff -u src/sys/arch/sparc/conf/TADPOLE3GX:1.77 src/sys/arch/sparc/conf/TADPOLE3GX:1.77.2.1
--- src/sys/arch/sparc/conf/TADPOLE3GX:1.77	Sat Apr 13 08:23:00 2019
+++ src/sys/arch/sparc/conf/TADPOLE3GX	Wed May  1 12:18:59 2019
@@ -1,4 +1,4 @@
-# 	$NetBSD: TADPOLE3GX,v 1.77 2019/04/13 08:23:00 isaki Exp $
+# 	$NetBSD: TADPOLE3GX,v 1.77.2.1 2019/05/01 12:18:59 isaki Exp $
 
 include "arch/sparc/conf/std.sparc"
 
@@ -317,7 +317,6 @@ pseudo-device	npf			# NPF packet filter
 ## /dev/audio support
 
 #options 	DBRI_DEBUG	# noisy debug output from the dbri driver
-options 	DBRI_BIG_BUFFER	# use bigger DMA buffers, for slow CPUs
 dbri0		at sbus0 slot ? offset ?		# SUNW,DBRI[s3|e]
 audio*		at audiobus?
 

Index: src/sys/dev/sbus/dbri.c
diff -u src/sys/dev/sbus/dbri.c:1.39.2.1 src/sys/dev/sbus/dbri.c:1.39.2.2
--- src/sys/dev/sbus/dbri.c:1.39.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/sbus/dbri.c	Wed May  1 12:18:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dbri.c,v 1.39.2.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: dbri.c,v 1.39.2.2 2019/05/01 12:18:59 isaki Exp $	*/
 
 /*
  * Copyright (C) 1997 Rudolf Koenig (rfkoe...@immd4.informatik.uni-erlangen.de)
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.39.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.39.2.2 2019/05/01 12:18:59 isaki Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -55,7 +55,6 @@ __KERNEL_RCSID(0, "$NetBSD: dbri.c,v 1.3
 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -132,9 +131,10 @@ static void	pipe_ts_link(struct dbri_sof
 static int	pipe_active(struct dbri_softc *, int);
 
 /* audio(9) stuff */
-static int	dbri_query_encoding(void *, struct audio_encoding *);
-static int	dbri_set_params(void *, int, int, struct audio_params *,
-struct audio_params *,stream_filter_list_t *, stream_filter_list_t *);
+static int	dbri_query_format(void *, audio_format_query_t *);
+static int	dbri_set_format(void *, int,
+const audio_params_t *, const audio_params_t *,
+audio_filter_reg_t *, audio_filter_reg_t *);
 static int	dbri_round_blocksize(void *, int, int, const audio_params_t *);
 static int	dbri_halt_output(void *);
 static int	dbri_halt_input(void *);
@@ -142,7 +142,6 @@ static int	dbri_getdev(void *, struct au
 static int	dbri_set_port(void *, mixer_ctrl_t *);
 static int	dbri_get_port(void *, mixer_ctrl_t *);
 static int	dbri_query_devinfo(void *, mixer_devinfo_t *);
-static size_t	dbri_round_buffersize(void *, int, size_t);
 static int	dbri_get_props(void *);
 static int	dbri_open(void *, int);
 static void	dbri_close(void *);
@@ -160,7 +159,6 @@ static void	dbri_get_locks(void *, kmute
 
 static void	*dbri_malloc(void *, int, size_t);
 static void	dbri_free(void *, void *, size_t);
-static paddr_t	dbri_mappage(void *, void *, off_t, int);
 static void	dbri_set_power(struct dbri_softc *, int);
 static void	dbri_bring_up(struct dbri_softc *);
 static bool	dbri_suspend(device_t, const pmf_qual_t *);
@@ -179,8 +177,8 @@ struct audio_device dbri_device = {
 struct audio_hw_if dbri_hw_if = {
 	.open			= db

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-05-01 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 09:41:50 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c

Log Message:
Use __nothing macro.


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.4 -r1.67.2.5 src/sys/dev/pci/emuxki.c

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

Modified files:

Index: src/sys/dev/pci/emuxki.c
diff -u src/sys/dev/pci/emuxki.c:1.67.2.4 src/sys/dev/pci/emuxki.c:1.67.2.5
--- src/sys/dev/pci/emuxki.c:1.67.2.4	Wed May  1 06:34:46 2019
+++ src/sys/dev/pci/emuxki.c	Wed May  1 09:41:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: emuxki.c,v 1.67.2.4 2019/05/01 06:34:46 isaki Exp $	*/
+/*	$NetBSD: emuxki.c,v 1.67.2.5 2019/05/01 09:41:50 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.4 2019/05/01 06:34:46 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.5 2019/05/01 09:41:50 isaki Exp $");
 
 #include 
 #include 
@@ -71,8 +71,8 @@ __KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1
 # define DPRINTF(fmt...)	do { if (emudebug) printf(fmt); } while (0)
 # define DPRINTFN(n,fmt...)	do { if (emudebug>=(n)) printf(fmt); } while (0)
 #else
-# define DPRINTF(fmt...)	do { } while (0)
-# define DPRINTFN(n,fmt...)	do { } while (0)
+# define DPRINTF(fmt...)	__nothing
+# define DPRINTFN(n,fmt...)	__nothing
 #endif
 
 /*



CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-30 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 06:34:46 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c
Removed Files:
src/sys/dev/pci [isaki-audio2]: emuxkivar.h

Log Message:
Reimplement emuxki driver.
- Use single voice per playback and per recording.
- Use fixed format, 2ch/48kHz, to simplify.
- Fix several problems in previous driver.
  And now it works even on alpha!
The driver is written by Y.Sugahara.  Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.3 -r1.67.2.4 src/sys/dev/pci/emuxki.c
cvs rdiff -u -r1.13 -r0 src/sys/dev/pci/emuxkivar.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/dev/pci/emuxki.c
diff -u src/sys/dev/pci/emuxki.c:1.67.2.3 src/sys/dev/pci/emuxki.c:1.67.2.4
--- src/sys/dev/pci/emuxki.c:1.67.2.3	Wed May  1 06:03:14 2019
+++ src/sys/dev/pci/emuxki.c	Wed May  1 06:34:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: emuxki.c,v 1.67.2.3 2019/05/01 06:03:14 isaki Exp $	*/
+/*	$NetBSD: emuxki.c,v 1.67.2.4 2019/05/01 06:34:46 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -30,147 +30,227 @@
  */
 
 /*
- * Driver for Creative Labs SBLive! series and probably PCI512.
- *
- * Known bugs:
- * - inversed stereo at ac97 codec level
- *   (XXX jdolecek - don't see the problem? maybe because auvia(4) has
- *it swapped too?)
- * - bass disappear when you plug rear jack-in on Cambridge FPS2000 speakers
- *   (and presumably all speakers that support front and rear jack-in)
- *
- * TODO:
- * - Digital Outputs
- * - (midi/mpu),joystick support
- * - Multiple voices play (problem with /dev/audio architecture)
- * - Multiple sources recording (Pb with audio(4))
- * - Independent modification of each channel's parameters (via mixer ?)
- * - DSP FX patches (to make fx like chipmunk)
+ * EMU10K1 single voice driver
+ * o. only 1 voice playback, 1 recording
+ * o. only s16le 2ch 48k
+ * This makes it simple to control buffers and interrupts
+ * while satisfying playback and recording quality.
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.3 2019/05/01 06:03:14 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.4 2019/05/01 06:34:46 isaki Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
 #include 
 #include 
 
+#include 
 #include 
 #include 
-#include 
+
 #include 
-#include 
 
-/* autoconf goo */
-static int	emuxki_match(device_t, cfdata_t, void *);
-static void	emuxki_attach(device_t, device_t, void *);
-static int	emuxki_detach(device_t, int);
+/* #define EMUXKI_DEBUG 1 */
+#ifdef EMUXKI_DEBUG
+#define emudebug EMUXKI_DEBUG
+# define DPRINTF(fmt...)	do { if (emudebug) printf(fmt); } while (0)
+# define DPRINTFN(n,fmt...)	do { if (emudebug>=(n)) printf(fmt); } while (0)
+#else
+# define DPRINTF(fmt...)	do { } while (0)
+# define DPRINTFN(n,fmt...)	do { } while (0)
+#endif
 
-/* DMA mem mgmt */
-static struct dmamem *dmamem_alloc(bus_dma_tag_t, size_t, bus_size_t,
-		int);
-static void	dmamem_free(struct dmamem *);
+/*
+ * PCI
+ * Note: emuxki's page table entry uses only 31bit addressing.
+ *   (Maybe, later chip has 32bit mode, but it isn't used now.)
+ */
 
-/* Emu10k1 init & shutdown */
-static int	emuxki_init(struct emuxki_softc *);
-static void	emuxki_shutdown(struct emuxki_softc *);
+#define EMU_PCI_CBIO		(0x10)
+#define EMU_SUBSYS_APS		(0x40011102)
 
-/* Emu10k1 mem mgmt */
-static void	*emuxki_pmem_alloc(struct emuxki_softc *, size_t);
-static void	*emuxki_rmem_alloc(struct emuxki_softc *, size_t);
+#define EMU_PTESIZE		(4096)
+#define EMU_MINPTE		(3)
+/*
+ * Hardware limit of PTE is 4096 entry but it's too big for single voice.
+ * Reasonable candidate is:
+ *  48kHz * 2ch * 2byte * 1sec * 3buf/EMU_PTESIZE = 141
+ * and then round it up to 2^n.
+ */
+#define EMU_MAXPTE		(256)
+#define EMU_NUMCHAN		(64)
+
+/*
+ * Internal recording DMA buffer
+ */
+/* Recommend the same size as EMU_PTESIZE to be symmetrical for play/rec */
+#define EMU_REC_DMABLKSIZE	(4096)
+/* must be EMU_REC_DMABLKSIZE * 2 */
+#define EMU_REC_DMASIZE		(8192)
+/* must be EMU_RECBS_BUFSIZE_(EMU_REC_DMASIZE) */
+#define EMU_REC_BUFSIZE_RECBS	EMU_RECBS_BUFSIZE_8192
 
 /*
- * Emu10k1 channels funcs : There is no direct access to channels, everything
- * is done through voices I will at least provide channel based fx params
- * modification, later...
+ * DMA memory management
  */
 
-/* Emu10k1 voice mgmt */
-static struct emuxki_voice *emuxki_voice_new(struct emuxki_softc *,
-		uint8_t);
-static void	emuxki_voice_delete(struct emuxki_voice *);
-static int	emuxki_voice_set_audioparms(struct emuxki_softc *,
-	struct emuxki_voice *, uint8_t,
-	uint8_t, uint32_t);
-/* emuxki_voice_set_fxparms will come later, it'll need channel distinction */
-static int	emuxki_voice_set_

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-30 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed May  1 06:03:14 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: emuxki.c

Log Message:
Adapt to audio2.
- XXX New set_format is not implemented at this point.
  This implementation can not adapt to audio2 (and it also has not
  worked since netbsd-8).
  The driver supports multiple hardware stream which is named 'voice'.
  This voice was allocated at open() and was deallocated at close().
  However, in order to support mixing, some interfaces such as
  set_params() (or set_format in audio2) has to be called before open().


To generate a diff of this commit:
cvs rdiff -u -r1.67.2.2 -r1.67.2.3 src/sys/dev/pci/emuxki.c

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

Modified files:

Index: src/sys/dev/pci/emuxki.c
diff -u src/sys/dev/pci/emuxki.c:1.67.2.2 src/sys/dev/pci/emuxki.c:1.67.2.3
--- src/sys/dev/pci/emuxki.c:1.67.2.2	Sun Apr 21 07:59:01 2019
+++ src/sys/dev/pci/emuxki.c	Wed May  1 06:03:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: emuxki.c,v 1.67.2.2 2019/04/21 07:59:01 isaki Exp $	*/
+/*	$NetBSD: emuxki.c,v 1.67.2.3 2019/05/01 06:03:14 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.2 2019/04/21 07:59:01 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.67.2.3 2019/05/01 06:03:14 isaki Exp $");
 
 #include 
 #include 
@@ -64,8 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1
 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -134,10 +132,10 @@ static void	emuxki_stream_halt(struct em
 static int	emuxki_open(void *, int);
 static void	emuxki_close(void *);
 
-static int	emuxki_query_encoding(void *, struct audio_encoding *);
-static int	emuxki_set_params(void *, int, int, audio_params_t *,
-		audio_params_t *, stream_filter_list_t *,
-		stream_filter_list_t *);
+static int	emuxki_query_format(void *, audio_format_query_t *);
+static int	emuxki_set_format(void *, int,
+		const audio_params_t *, const audio_params_t *,
+		audio_filter_reg_t *, audio_filter_reg_t *);
 
 static int	emuxki_round_blocksize(void *, int, int, const audio_params_t *);
 static size_t	emuxki_round_buffersize(void *, int, size_t);
@@ -157,7 +155,6 @@ static int	emuxki_query_devinfo(void *, 
 static void*emuxki_allocm(void *, int, size_t);
 static void	emuxki_freem(void *, void *, size_t);
 
-static paddr_t	emuxki_mappage(void *, void *, off_t, int);
 static int	emuxki_get_props(void *);
 static void	emuxki_get_locks(void *, kmutex_t **, kmutex_t **);
 
@@ -180,8 +177,8 @@ CFATTACH_DECL_NEW(emuxki, sizeof(struct 
 static const struct audio_hw_if emuxki_hw_if = {
 	.open			= emuxki_open,
 	.close			= emuxki_close,
-	.query_encoding		= emuxki_query_encoding,
-	.set_params		= emuxki_set_params,
+	.query_format		= emuxki_query_format,
+	.set_format		= emuxki_set_format,
 	.round_blocksize	= emuxki_round_blocksize,
 	.halt_output		= emuxki_halt_output,
 	.halt_input		= emuxki_halt_input,
@@ -192,7 +189,6 @@ static const struct audio_hw_if emuxki_h
 	.allocm			= emuxki_allocm,
 	.freem			= emuxki_freem,
 	.round_buffersize	= emuxki_round_buffersize,
-	.mappage		= emuxki_mappage,
 	.get_props		= emuxki_get_props,
 	.trigger_output		= emuxki_trigger_output,
 	.trigger_input		= emuxki_trigger_input,
@@ -2089,124 +2085,20 @@ emuxki_close(void *addr)
 }
 
 static int
-emuxki_query_encoding(void *addr, struct audio_encoding *fp)
+emuxki_query_format(void *addr, audio_format_query_t *afp)
 {
-#ifdef EMUXKI_DEBUG
-	struct emuxki_softc *sc;
-
-	sc = addr;
-	printf("%s: emuxki_query_encoding called\n", device_xname(sc->sc_dev));
-#endif
-
-	switch (fp->index) {
-	case 0:
-		strcpy(fp->name, AudioEulinear);
-		fp->encoding = AUDIO_ENCODING_ULINEAR;
-		fp->precision = 8;
-		fp->flags = 0;
-		break;
-	case 1:
-		strcpy(fp->name, AudioEmulaw);
-		fp->encoding = AUDIO_ENCODING_ULAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 2:
-		strcpy(fp->name, AudioEalaw);
-		fp->encoding = AUDIO_ENCODING_ALAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 3:
-		strcpy(fp->name, AudioEslinear);
-		fp->encoding = AUDIO_ENCODING_SLINEAR;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 4:
-		strcpy(fp->name, AudioEslinear_le);
-		fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
-		fp->precision = 16;
-		fp->flags = 0;
-		break;
-	case 5:
-		strcpy(fp->name, AudioEulinear_le);
-		fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
-		fp->precision = 16;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 6:
-		strcpy(fp->name, AudioEslinear_be);
-		fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
-		fp->precision = 16;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 7:
-		strcpy(fp->name, AudioEulinear_be);
-		fp->encoding = AUDIO_ENCODING_ULINEAR_BE;
-		fp->precision = 

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-29 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Apr 30 06:05:02 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: eap.c

Log Message:
More adapt to audio2.
- Use set_format.
- Remove an empty method.
- XXX DAC1 and secondary audio device support should be removed.
  Now mixing two (or more) sources is done by audio layer.


To generate a diff of this commit:
cvs rdiff -u -r1.99.2.2 -r1.99.2.3 src/sys/dev/pci/eap.c

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

Modified files:

Index: src/sys/dev/pci/eap.c
diff -u src/sys/dev/pci/eap.c:1.99.2.2 src/sys/dev/pci/eap.c:1.99.2.3
--- src/sys/dev/pci/eap.c:1.99.2.2	Sun Apr 21 07:55:25 2019
+++ src/sys/dev/pci/eap.c	Tue Apr 30 06:05:02 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: eap.c,v 1.99.2.2 2019/04/21 07:55:25 isaki Exp $	*/
+/*	$NetBSD: eap.c,v 1.99.2.3 2019/04/30 06:05:02 isaki Exp $	*/
 /*  $OpenBSD: eap.c,v 1.6 1999/10/05 19:24:42 csapuntz Exp $ */
 
 /*
@@ -50,8 +50,13 @@
  * ftp://download.intel.com/ial/scalableplatforms/audio/ac97r21.pdf
  */
 
+/*
+ * TODO:
+ * - Remove DAC1 and secondary audio device support.
+ */
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: eap.c,v 1.99.2.2 2019/04/21 07:55:25 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: eap.c,v 1.99.2.3 2019/04/30 06:05:02 isaki Exp $");
 
 #include "midi.h"
 #include "joy_eap.h"
@@ -69,7 +74,6 @@ __KERNEL_RCSID(0, "$NetBSD: eap.c,v 1.99
 #include 
 
 #include 
-#include 
 #include 
 
 #include 
@@ -109,9 +113,9 @@ CFATTACH_DECL_NEW(eap, sizeof(struct eap
 
 static int	eap_open(void *, int);
 static int	eap_query_format(void *, struct audio_format_query *);
-static int	eap_set_params(void *, int, int, audio_params_t *,
-			   audio_params_t *, stream_filter_list_t *,
-			   stream_filter_list_t *);
+static int	eap_set_format(void *, int,
+			   const audio_params_t *, const audio_params_t *,
+			   audio_filter_reg_t *, audio_filter_reg_t *);
 static int	eap_trigger_output(void *, void *, void *, int,
    void (*)(void *), void *,
    const audio_params_t *);
@@ -129,7 +133,6 @@ static int	eap1371_mixer_get_port(void *
 static int	eap1370_query_devinfo(void *, mixer_devinfo_t *);
 static void	*eap_malloc(void *, int, size_t);
 static void	eap_free(void *, void *, size_t);
-static size_t	eap_round_buffersize(void *, int, size_t);
 static int	eap_get_props(void *);
 static void	eap1370_set_mixer(struct eap_softc *, int, int);
 static uint32_t eap1371_src_wait(struct eap_softc *);
@@ -157,7 +160,7 @@ static void	eap_uart_txrdy(struct eap_so
 static const struct audio_hw_if eap1370_hw_if = {
 	.open			= eap_open,
 	.query_format		= eap_query_format,
-	.set_params		= eap_set_params,
+	.set_format		= eap_set_format,
 	.halt_output		= eap_halt_output,
 	.halt_input		= eap_halt_input,
 	.getdev			= eap_getdev,
@@ -166,7 +169,6 @@ static const struct audio_hw_if eap1370_
 	.query_devinfo		= eap1370_query_devinfo,
 	.allocm			= eap_malloc,
 	.freem			= eap_free,
-	.round_buffersize	= eap_round_buffersize,
 	.get_props		= eap_get_props,
 	.trigger_output		= eap_trigger_output,
 	.trigger_input		= eap_trigger_input,
@@ -176,7 +178,7 @@ static const struct audio_hw_if eap1370_
 static const struct audio_hw_if eap1371_hw_if = {
 	.open			= eap_open,
 	.query_format		= eap_query_format,
-	.set_params		= eap_set_params,
+	.set_format		= eap_set_format,
 	.halt_output		= eap_halt_output,
 	.halt_input		= eap_halt_input,
 	.getdev			= eap_getdev,
@@ -185,7 +187,6 @@ static const struct audio_hw_if eap1371_
 	.query_devinfo		= eap1371_query_devinfo,
 	.allocm			= eap_malloc,
 	.freem			= eap_free,
-	.round_buffersize	= eap_round_buffersize,
 	.get_props		= eap_get_props,
 	.trigger_output		= eap_trigger_output,
 	.trigger_input		= eap_trigger_input,
@@ -209,24 +210,19 @@ static struct audio_device eap_device = 
 	"eap"
 };
 
-#define EAP_NFORMATS	4
-#define EAP_FORMAT(enc, prec, ch, chmask) \
-	{ \
-		.mode		= AUMODE_PLAY | AUMODE_RECORD, \
-		.encoding	= (enc), \
-		.validbits	= (prec), \
-		.precision	= (prec), \
-		.channels	= (ch), \
-		.channel_mask	= (chmask), \
-		.frequency_type	= 0, \
-		.frequency	= { 4000, 48000 }, \
-	}
-static const struct audio_format eap_formats[EAP_NFORMATS] = {
-	EAP_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	EAP_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	EAP_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-	EAP_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
+static const struct audio_format eap_formats[] = {
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 2,
+		.frequency	= { 4000, 48000 },
+	},
 };
+#define EAP_NFORMATS	__arraycount(eap_formats)
 
 static int
 eap_match(device_t parent, cfdata_t match, void *aux)
@@ -944,54 +940,37 @@ eap_query_format(void *addr, struct audi

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-29 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Mon Apr 29 09:30:18 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: sv.c

Log Message:
Adapt to audio2.
- Drop INDEPENDENT property.  Both play and rec seems to share the
  sample rate (however, they require different calculations?).
- XXX It's better to modify frequency list more strictly.
- Remove obsoleted and empty methods.


To generate a diff of this commit:
cvs rdiff -u -r1.54.2.1 -r1.54.2.2 src/sys/dev/pci/sv.c

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

Modified files:

Index: src/sys/dev/pci/sv.c
diff -u src/sys/dev/pci/sv.c:1.54.2.1 src/sys/dev/pci/sv.c:1.54.2.2
--- src/sys/dev/pci/sv.c:1.54.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/sv.c	Mon Apr 29 09:30:18 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: sv.c,v 1.54.2.1 2019/04/21 05:11:22 isaki Exp $ */
+/*  $NetBSD: sv.c,v 1.54.2.2 2019/04/29 09:30:18 isaki Exp $ */
 /*  $OpenBSD: sv.c,v 1.2 1998/07/13 01:50:15 csapuntz Exp $ */
 
 /*
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sv.c,v 1.54.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sv.c,v 1.54.2.2 2019/04/29 09:30:18 isaki Exp $");
 
 #include 
 #include 
@@ -81,8 +81,6 @@ __KERNEL_RCSID(0, "$NetBSD: sv.c,v 1.54.
 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -141,10 +139,10 @@ static int	sv_freemem(struct sv_softc *,
 static void	sv_init_mixer(struct sv_softc *);
 
 static int	sv_open(void *, int);
-static int	sv_query_encoding(void *, struct audio_encoding *);
-static int	sv_set_params(void *, int, int, audio_params_t *,
-			  audio_params_t *, stream_filter_list_t *,
-			  stream_filter_list_t *);
+static int	sv_query_format(void *, audio_format_query_t *);
+static int	sv_set_format(void *, int,
+			  const audio_params_t *, const audio_params_t *,
+			  audio_filter_reg_t *, audio_filter_reg_t *);
 static int	sv_round_blocksize(void *, int, int, const audio_params_t *);
 static int	sv_trigger_output(void *, void *, void *, int, void (*)(void *),
   void *, const audio_params_t *);
@@ -158,8 +156,6 @@ static int	sv_mixer_get_port(void *, mix
 static int	sv_query_devinfo(void *, mixer_devinfo_t *);
 static void *	sv_malloc(void *, int, size_t);
 static void	sv_free(void *, void *, size_t);
-static size_t	sv_round_buffersize(void *, int, size_t);
-static paddr_t	sv_mappage(void *, void *, off_t, int);
 static int	sv_get_props(void *);
 static void	sv_get_locks(void *, kmutex_t **, kmutex_t **);
 
@@ -169,8 +165,8 @@ voidsv_dumpregs(struct sv_softc *sc)
 
 static const struct audio_hw_if sv_hw_if = {
 	.open			= sv_open,
-	.query_encoding		= sv_query_encoding,
-	.set_params		= sv_set_params,
+	.query_format		= sv_query_format,
+	.set_format		= sv_set_format,
 	.round_blocksize	= sv_round_blocksize,
 	.halt_output		= sv_halt_output,
 	.halt_input		= sv_halt_input,
@@ -180,32 +176,25 @@ static const struct audio_hw_if sv_hw_if
 	.query_devinfo		= sv_query_devinfo,
 	.allocm			= sv_malloc,
 	.freem			= sv_free,
-	.round_buffersize	= sv_round_buffersize,
-	.mappage		= sv_mappage,
 	.get_props		= sv_get_props,
 	.trigger_output		= sv_trigger_output,
 	.trigger_input		= sv_trigger_input,
 	.get_locks		= sv_get_locks,
 };
 
-#define SV_NFORMATS	4
-#define SV_FORMAT(enc, prec, ch, chmask) \
-	{ \
-		.mode		= AUMODE_PLAY | AUMODE_RECORD, \
-		.encoding	= (enc), \
-		.validbits	= (prec), \
-		.precision	= (prec), \
-		.channels	= (ch), \
-		.channel_mask	= (chmask), \
-		.frequency_type	= 0, \
-		.frequency	= { 2000, 48000 }, \
-	}
-static const struct audio_format sv_formats[SV_NFORMATS] = {
-	SV_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	SV_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	SV_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-	SV_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
+static const struct audio_format sv_formats[] = {
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 0,
+		.frequency	= { 2000, 48000 },
+	},
 };
+#define SV_NFORMATS	__arraycount(sv_formats)
 
 
 static void
@@ -582,105 +571,25 @@ sv_open(void *addr, int flags)
 }
 
 static int
-sv_query_encoding(void *addr, struct audio_encoding *fp)
+sv_query_format(void *addr, audio_format_query_t *afp)
 {
 
-	switch (fp->index) {
-	case 0:
-		strcpy(fp->name, AudioEulinear);
-		fp->encoding = AUDIO_ENCODING_ULINEAR;
-		fp->precision = 8;
-		fp->flags = 0;
-		return 0;
-	case 1:
-		strcpy(fp->name, AudioEmulaw);
-		fp->encoding = AUDIO_ENCODING_ULAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		return 0;
-	case 2:
-		strcpy(fp->name, AudioEalaw);
-		fp->encoding = AUDIO_ENCODING_ALAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		return 0;
-	case 3:

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-29 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Mon Apr 29 09:32:07 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: yds.c ydsvar.h

Log Message:
Adapt to audio2.


To generate a diff of this commit:
cvs rdiff -u -r1.61.2.1 -r1.61.2.2 src/sys/dev/pci/yds.c
cvs rdiff -u -r1.12 -r1.12.10.1 src/sys/dev/pci/ydsvar.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/dev/pci/yds.c
diff -u src/sys/dev/pci/yds.c:1.61.2.1 src/sys/dev/pci/yds.c:1.61.2.2
--- src/sys/dev/pci/yds.c:1.61.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/yds.c	Mon Apr 29 09:32:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: yds.c,v 1.61.2.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: yds.c,v 1.61.2.2 2019/04/29 09:32:07 isaki Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001 Kazuki Sakamoto and Minoura Makoto.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: yds.c,v 1.61.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: yds.c,v 1.61.2.2 2019/04/29 09:32:07 isaki Exp $");
 
 #include "mpu.h"
 
@@ -57,8 +57,6 @@ __KERNEL_RCSID(0, "$NetBSD: yds.c,v 1.61
 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -151,10 +149,10 @@ CFATTACH_DECL_NEW(yds, sizeof(struct yds
 
 static int	yds_open(void *, int);
 static void	yds_close(void *);
-static int	yds_query_encoding(void *, struct audio_encoding *);
-static int	yds_set_params(void *, int, int, audio_params_t *,
-			   audio_params_t *, stream_filter_list_t *,
-			   stream_filter_list_t *);
+static int	yds_query_format(void *, audio_format_query_t *);
+static int	yds_set_format(void *, int,
+			   const audio_params_t *, const audio_params_t *,
+			   audio_filter_reg_t *, audio_filter_reg_t *);
 static int	yds_round_blocksize(void *, int, int, const audio_params_t *);
 static int	yds_trigger_output(void *, void *, void *, int,
    void (*)(void *), void *,
@@ -170,7 +168,6 @@ static int	yds_mixer_get_port(void *, mi
 static void *	yds_malloc(void *, int, size_t);
 static void	yds_free(void *, void *, size_t);
 static size_t	yds_round_buffersize(void *, int, size_t);
-static paddr_t	yds_mappage(void *, void *, off_t, int);
 static int	yds_get_props(void *);
 static int	yds_query_devinfo(void *, mixer_devinfo_t *);
 static void	yds_get_locks(void *, kmutex_t **, kmutex_t **);
@@ -206,8 +203,8 @@ static const struct audio_hw_if yds_hw_i
 	.open		  = yds_open,
 	.close		  = yds_close,
 	.drain		  = NULL,
-	.query_encoding	  = yds_query_encoding,
-	.set_params	  = yds_set_params,
+	.query_format	  = yds_query_format,
+	.set_format	  = yds_set_format,
 	.round_blocksize  = yds_round_blocksize,
 	.commit_settings  = NULL,
 	.init_output	  = NULL,
@@ -225,7 +222,6 @@ static const struct audio_hw_if yds_hw_i
 	.allocm		  = yds_malloc,
 	.freem		  = yds_free,
 	.round_buffersize = yds_round_buffersize,
-	.mappage	  = yds_mappage,
 	.get_props	  = yds_get_props,
 	.trigger_output	  = yds_trigger_output,
 	.trigger_input	  = yds_trigger_input,
@@ -267,22 +263,18 @@ static const struct {
 #define YDS_CAP_BITS	"\020\005P44\004LEGFLEX\003LEGSEL\002MCODE1E\001MCODE1"
 #endif
 
-#define YDS_FORMAT(enc, prec, ch, chmask) \
-	{ \
-		.mode		= AUMODE_PLAY | AUMODE_RECORD, \
-		.encoding	= (enc), \
-		.validbits	= (prec), \
-		.precision	= (prec), \
-		.channels	= (ch), \
-		.channel_mask	= (chmask), \
-		.frequency_type	= 0, \
-		.frequency	= { 4000, 48000 }, \
-	}
 static const struct audio_format yds_formats[] = {
-	YDS_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	YDS_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	YDS_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-	YDS_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 8,
+		.frequency	=
+		{ 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000 },
+	},
 };
 #define	YDS_NFORMATS	(sizeof(yds_formats) / sizeof(struct audio_format))
 
@@ -937,13 +929,6 @@ detected:
 		}
 	}
 
-	if (0 != auconv_create_encodings(yds_formats, YDS_NFORMATS,
-	&sc->sc_encodings)) {
-		mutex_destroy(&sc->sc_lock);
-		mutex_destroy(&sc->sc_intr_lock);
-		return;
-	}
-
 	audio_attach_mi(&yds_hw_if, sc, self);
 
 	sc->sc_legacy_iot = pa->pa_iot;
@@ -1253,29 +1238,17 @@ yds_close(void *addr)
 }
 
 static int
-yds_query_encoding(void *addr, struct audio_encoding *fp)
+yds_query_format(void *addr, audio_format_query_t *afp)
 {
-	struct yds_softc *sc;
 
-	sc = addr;
-	return auconv_query_encoding(sc->sc_encodings, fp);
+	return audio_query_format(yds_formats, YDS_NFORMATS, afp);
 }
 
 static int
-yds_set_params(void *addr, int setmode, int usemode,
-	   audio_params_t *play, audio_params_t* rec,
-	   stream_filter_list_t *pfil, stream_filter_list_t *rfil)

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-28 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 07:48:15 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: neo.c

Log Message:
Adapt to audio2.
- XXX In audio2, number of blocks must be 3 or greater, so
  modify round_blocksize() to return bufsize / 4.
- XXX Doesn't neo_trigger_input() need to subtract ssz from
  buffer end like trigger_output()?


To generate a diff of this commit:
cvs rdiff -u -r1.52.2.1 -r1.52.2.2 src/sys/dev/pci/neo.c

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

Modified files:

Index: src/sys/dev/pci/neo.c
diff -u src/sys/dev/pci/neo.c:1.52.2.1 src/sys/dev/pci/neo.c:1.52.2.2
--- src/sys/dev/pci/neo.c:1.52.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/neo.c	Sun Apr 28 07:48:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: neo.c,v 1.52.2.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: neo.c,v 1.52.2.2 2019/04/28 07:48:15 isaki Exp $	*/
 
 /*
  * Copyright (c) 1999 Cameron Grant 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: neo.c,v 1.52.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: neo.c,v 1.52.2.2 2019/04/28 07:48:15 isaki Exp $");
 
 #include 
 #include 
@@ -43,8 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: neo.c,v 1.52
 #include 
 
 #include 
-#include 
-#include 
 
 #include 
 
@@ -176,11 +174,12 @@ static int	nm_init(struct neo_softc *);
 static int	neo_match(device_t, cfdata_t, void *);
 static void	neo_attach(device_t, device_t, void *);
 static int	neo_intr(void *);
+static int	neo_rate2index(u_int);
 
-static int	neo_query_encoding(void *, struct audio_encoding *);
-static int	neo_set_params(void *, int, int, audio_params_t *,
-			   audio_params_t *, stream_filter_list_t *,
-			   stream_filter_list_t *);
+static int	neo_query_format(void *, audio_format_query_t *);
+static int	neo_set_format(void *, int,
+			   const audio_params_t *, const audio_params_t *,
+			   audio_filter_reg_t *, audio_filter_reg_t *);
 static int	neo_round_blocksize(void *, int, int, const audio_params_t *);
 static int	neo_trigger_output(void *, void *, void *, int,
    void (*)(void *), void *,
@@ -202,7 +201,6 @@ static int	neo_query_devinfo(void *, mix
 static void *	neo_malloc(void *, int, size_t);
 static void	neo_free(void *, void *, size_t);
 static size_t	neo_round_buffersize(void *, int, size_t);
-static paddr_t	neo_mappage(void *, void *, off_t, int);
 static int	neo_get_props(void *);
 static void	neo_get_locks(void *, kmutex_t **, kmutex_t **);
 
@@ -215,44 +213,30 @@ static struct audio_device neo_device = 
 	"neo"
 };
 
-/* The actual rates supported by the card. */
-static const int samplerates[9] = {
-	8000,
-	11025,
-	16000,
-	22050,
-	24000,
-	32000,
-	44100,
-	48000,
-	
-};
-
-#define NEO_NFORMATS	4
-#define NEO_FORMAT(enc, prec, ch, chmask) \
-	{ \
-		.mode		= AUMODE_PLAY | AUMODE_RECORD, \
-		.encoding	= (enc), \
-		.validbits	= (prec), \
-		.precision	= (prec), \
-		.channels	= (ch), \
-		.channel_mask	= (chmask), \
-		.frequency_type	= 8, \
-		.frequency	= \
-		{ 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000 }, \
-	}
-static const struct audio_format neo_formats[NEO_NFORMATS] = {
-	NEO_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	NEO_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	NEO_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-	NEO_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
+/*
+ * The frequency list in this format is also referred from neo_rate2index().
+ * So don't rearrange or delete entries.
+ */
+static const struct audio_format neo_formats[] = {
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 8,
+		.frequency	=
+		{ 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000 },
+	},
 };
+#define NEO_NFORMATS	__arraycount(neo_formats)
 
 /*  */
 
 static const struct audio_hw_if neo_hw_if = {
-	.query_encoding		= neo_query_encoding,
-	.set_params		= neo_set_params,
+	.query_format		= neo_query_format,
+	.set_format		= neo_set_format,
 	.round_blocksize	= neo_round_blocksize,
 	.halt_output		= neo_halt_output,
 	.halt_input		= neo_halt_input,
@@ -263,7 +247,6 @@ static const struct audio_hw_if neo_hw_i
 	.allocm			= neo_malloc,
 	.freem			= neo_free,
 	.round_buffersize	= neo_round_buffersize,
-	.mappage		= neo_mappage,
 	.get_props		= neo_get_props,
 	.trigger_output		= neo_trigger_output,
 	.trigger_input		= neo_trigger_input,
@@ -722,75 +705,38 @@ neo_flags_codec(void *v)
 }
 
 static int
-neo_query_encoding(void *addr, struct audio_encoding *fp)
+neo_query_format(void *addr, audio_format_query_t *afp)
 {
 
-	switch (fp->index) {
-	case 0:
-		strcpy(fp->name, AudioEulinear);
-		fp->encoding = AUDIO_ENCODING_ULINEAR;
-		fp->precision = 8;

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-28 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 07:01:45 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: gcscaudio.c

Log Message:
Adapt to audio2.


To generate a diff of this commit:
cvs rdiff -u -r1.16.2.1 -r1.16.2.2 src/sys/dev/pci/gcscaudio.c

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

Modified files:

Index: src/sys/dev/pci/gcscaudio.c
diff -u src/sys/dev/pci/gcscaudio.c:1.16.2.1 src/sys/dev/pci/gcscaudio.c:1.16.2.2
--- src/sys/dev/pci/gcscaudio.c:1.16.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/gcscaudio.c	Sun Apr 28 07:01:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcscaudio.c,v 1.16.2.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: gcscaudio.c,v 1.16.2.2 2019/04/28 07:01:45 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 SHIMIZU Ryo 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gcscaudio.c,v 1.16.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gcscaudio.c,v 1.16.2.2 2019/04/28 07:01:45 isaki Exp $");
 
 #include 
 #include 
@@ -40,8 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: gcscaudio.c,
 
 #include 
 #include 
-#include 
-#include 
+
 #include 
 #include 
 
@@ -101,7 +100,6 @@ struct gcscaudio_softc {
 #define GCSCAUDIO_MAXFORMATS	4
 	struct audio_format sc_formats[GCSCAUDIO_MAXFORMATS];
 	int sc_nformats;
-	struct audio_encoding_set *sc_encodings;
 
 	/* AC97 codec */
 	struct ac97_host_if host_if;
@@ -129,10 +127,10 @@ static void gcscaudio_attach(device_t, d
 /* for audio_hw_if */
 static int gcscaudio_open(void *, int);
 static void gcscaudio_close(void *);
-static int gcscaudio_query_encoding(void *, struct audio_encoding *);
-static int gcscaudio_set_params(void *, int, int, audio_params_t *,
-audio_params_t *, stream_filter_list_t *,
-stream_filter_list_t *);
+static int gcscaudio_query_format(void *, audio_format_query_t *);
+static int gcscaudio_set_format(void *, int,
+const audio_params_t *, const audio_params_t *,
+audio_filter_reg_t *, audio_filter_reg_t *);
 static int gcscaudio_round_blocksize(void *, int, int, const audio_params_t *);
 static int gcscaudio_halt_output(void *);
 static int gcscaudio_halt_input(void *);
@@ -143,7 +141,6 @@ static int gcscaudio_query_devinfo(void 
 static void *gcscaudio_malloc(void *, int, size_t);
 static void gcscaudio_free(void *, void *, size_t);
 static size_t gcscaudio_round_buffersize(void *, int, size_t);
-static paddr_t gcscaudio_mappage(void *, void *, off_t, int);
 static int gcscaudio_get_props(void *);
 static int gcscaudio_trigger_output(void *, void *, void *, int,
 void (*)(void *), void *,
@@ -166,9 +163,6 @@ static void gcscaudio_spdif_event_codec(
 static int gcscaudio_append_formats(struct gcscaudio_softc *,
 const struct audio_format *);
 static int gcscaudio_wait_ready_codec(struct gcscaudio_softc *sc, const char *);
-static int gcscaudio_set_params_ch(struct gcscaudio_softc *,
-   struct gcscaudio_softc_ch *, int,
-   audio_params_t *, stream_filter_list_t *);
 static int gcscaudio_allocate_dma(struct gcscaudio_softc *, size_t, void **,
   bus_dma_segment_t *, int, int *,
   bus_dmamap_t *);
@@ -188,8 +182,8 @@ static const struct audio_hw_if gcscaudi
 	.open			= gcscaudio_open,
 	.close			= gcscaudio_close,
 	.drain			= NULL,
-	.query_encoding		= gcscaudio_query_encoding,
-	.set_params		= gcscaudio_set_params,
+	.query_format		= gcscaudio_query_format,
+	.set_format		= gcscaudio_set_format,
 	.round_blocksize	= gcscaudio_round_blocksize,
 	.commit_settings	= NULL,
 	.init_output		= NULL,
@@ -207,7 +201,6 @@ static const struct audio_hw_if gcscaudi
 	.allocm			= gcscaudio_malloc,
 	.freem			= gcscaudio_free,
 	.round_buffersize	= gcscaudio_round_buffersize,
-	.mappage		= gcscaudio_mappage,
 	.get_props		= gcscaudio_get_props,
 	.trigger_output		= gcscaudio_trigger_output,
 	.trigger_input		= gcscaudio_trigger_input,
@@ -350,18 +343,9 @@ gcscaudio_attach(device_t parent, device
 	}
 	mutex_exit(&sc->sc_lock);
 
-	if ((rc = auconv_create_encodings(sc->sc_formats, sc->sc_nformats,
-	&sc->sc_encodings)) != 0) {
-		aprint_error_dev(self,
-		"auconv_create_encoding: error=%d\n", rc);
-		goto attach_failure_codec;
-	}
-
 	audio_attach_mi(&gcscaudio_hw_if, sc, sc->sc_dev);
 	return;
 
-attach_failure_codec:
-	sc->codec_if->vtbl->detach(sc->codec_if);
 attach_failure_intr:
 	pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
 attach_failure_unmap:
@@ -506,87 +490,58 @@ gcscaudio_close(void *arg)
 }
 
 static int
-gcscaudio_query_encoding(void *arg, struct audio_encoding *fp)
+gcscaudio_query_format(void *arg, audio_format_query_t *afp)
 {
 	struct gcscaudio_softc *sc;
 
 	sc 

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 06:36:50 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: fms.c

Log Message:
Adapt to audio2.
- Searching nearest frequency is unnecessary in audio2.


To generate a diff of this commit:
cvs rdiff -u -r1.45.2.1 -r1.45.2.2 src/sys/dev/pci/fms.c

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

Modified files:

Index: src/sys/dev/pci/fms.c
diff -u src/sys/dev/pci/fms.c:1.45.2.1 src/sys/dev/pci/fms.c:1.45.2.2
--- src/sys/dev/pci/fms.c:1.45.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/fms.c	Sun Apr 28 06:36:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fms.c,v 1.45.2.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: fms.c,v 1.45.2.2 2019/04/28 06:36:50 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fms.c,v 1.45.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fms.c,v 1.45.2.2 2019/04/28 06:36:50 isaki Exp $");
 
 #include "mpu.h"
 
@@ -52,8 +52,6 @@ __KERNEL_RCSID(0, "$NetBSD: fms.c,v 1.45
 #include 
 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -75,10 +73,10 @@ static int	fms_match(device_t, cfdata_t,
 static void	fms_attach(device_t, device_t, void *);
 static int	fms_intr(void *);
 
-static int	fms_query_encoding(void *, struct audio_encoding *);
-static int	fms_set_params(void *, int, int, audio_params_t *,
-			   audio_params_t *, stream_filter_list_t *,
-			   stream_filter_list_t *);
+static int	fms_query_format(void *, audio_format_query_t *);
+static int	fms_set_format(void *, int,
+			   const audio_params_t *, const audio_params_t *,
+			   audio_filter_reg_t *, audio_filter_reg_t *);
 static int	fms_round_blocksize(void *, int, int, const audio_params_t *);
 static int	fms_halt_output(void *);
 static int	fms_halt_input(void *);
@@ -88,8 +86,6 @@ static int	fms_get_port(void *, mixer_ct
 static int	fms_query_devinfo(void *, mixer_devinfo_t *);
 static void	*fms_malloc(void *, int, size_t);
 static void	fms_free(void *, void *, size_t);
-static size_t	fms_round_buffersize(void *, int, size_t);
-static paddr_t	fms_mappage(void *, void *, off_t, int);
 static int	fms_get_props(void *);
 static int	fms_trigger_output(void *, void *, void *, int,
    void (*)(void *), void *,
@@ -108,10 +104,29 @@ static struct audio_device fms_device = 
 	"fms"
 };
 
+/*
+ * The frequency list in this format is also referred from fms_rate2index().
+ * So don't rearrange or delete entries.
+ */
+static const struct audio_format fms_formats[] = {
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 11,
+		.frequency	= { 5500, 8000, 9600, 11025, 16000, 19200,
+		22050, 32000, 38400, 44100, 48000},
+	},
+};
+#define FMS_NFORMATS	__arraycount(fms_formats)
+
 
 static const struct audio_hw_if fms_hw_if = {
-	.query_encoding		= fms_query_encoding,
-	.set_params		= fms_set_params,
+	.query_format		= fms_query_format,
+	.set_format		= fms_set_format,
 	.round_blocksize	= fms_round_blocksize,
 	.halt_output		= fms_halt_output,
 	.halt_input		= fms_halt_input,
@@ -121,8 +136,6 @@ static const struct audio_hw_if fms_hw_i
 	.query_devinfo		= fms_query_devinfo,
 	.allocm			= fms_malloc,
 	.freem			= fms_free,
-	.round_buffersize	= fms_round_buffersize,
-	.mappage		= fms_mappage,
 	.get_props		= fms_get_props,
 	.trigger_output		= fms_trigger_output,
 	.trigger_input		= fms_trigger_input,
@@ -133,6 +146,7 @@ static int	fms_attach_codec(void *, stru
 static int	fms_read_codec(void *, uint8_t, uint16_t *);
 static int	fms_write_codec(void *, uint8_t, uint16_t);
 static int	fms_reset_codec(void *);
+static int	fms_rate2index(u_int);
 
 #define FM_PCM_VOLUME		0x00
 #define FM_FM_VOLUME		0x02
@@ -462,145 +476,45 @@ fms_intr(void *arg)
 }
 
 static int
-fms_query_encoding(void *addr, struct audio_encoding *fp)
+fms_query_format(void *addr, audio_format_query_t *afp)
 {
 
-	switch (fp->index) {
-	case 0:
-		strcpy(fp->name, AudioEmulaw);
-		fp->encoding = AUDIO_ENCODING_ULAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		return 0;
-	case 1:
-		strcpy(fp->name, AudioEslinear_le);
-		fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
-		fp->precision = 16;
-		fp->flags = 0;
-		return 0;
-	case 2:
-		strcpy(fp->name, AudioEulinear);
-		fp->encoding = AUDIO_ENCODING_ULINEAR;
-		fp->precision = 8;
-		fp->flags = 0;
-		return 0;
-	case 3:
-		strcpy(fp->name, AudioEalaw);
-		fp->encoding = AUDIO_ENCODING_ALAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		return 0;
-	case 4:
-		strcpy(fp->name, AudioEulinear_le);
-		fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
-		fp->precision = 16;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		return 0;
-	case 5:
-		strcpy(f

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 05:07:00 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: eso.c

Log Message:
Don't release sc_lock on eso_halt_{input,output}.
halt_* is called with sc_lock && sc_intr_lock held.  This lock order
is first sc_lock and then sc_intr_lock.  So unlocking sc_lock with
sc_intr_lock held is wrong operation.  And cv_wait(sc_intr_lock) will
work even with sc_lock held.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.2 -r1.69.2.3 src/sys/dev/pci/eso.c

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

Modified files:

Index: src/sys/dev/pci/eso.c
diff -u src/sys/dev/pci/eso.c:1.69.2.2 src/sys/dev/pci/eso.c:1.69.2.3
--- src/sys/dev/pci/eso.c:1.69.2.2	Sun Apr 28 04:45:34 2019
+++ src/sys/dev/pci/eso.c	Sun Apr 28 05:07:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: eso.c,v 1.69.2.2 2019/04/28 04:45:34 isaki Exp $	*/
+/*	$NetBSD: eso.c,v 1.69.2.3 2019/04/28 05:07:00 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.69.2.2 2019/04/28 04:45:34 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.69.2.3 2019/04/28 05:07:00 isaki Exp $");
 
 #include "mpu.h"
 
@@ -784,13 +784,7 @@ eso_halt_output(void *hdl)
 	ESO_IO_A2DMAM_DMAENB);
 
 	sc->sc_pintr = NULL;
-	mutex_exit(&sc->sc_lock);
 	error = cv_timedwait_sig(&sc->sc_pcv, &sc->sc_intr_lock, sc->sc_pdrain);
-	if (!mutex_tryenter(&sc->sc_lock)) {
-		mutex_spin_exit(&sc->sc_intr_lock);
-		mutex_enter(&sc->sc_lock);
-		mutex_spin_enter(&sc->sc_intr_lock);
-	}
 
 	/* Shut down DMA completely. */
 	eso_write_mixreg(sc, ESO_MIXREG_A2C1, 0);
@@ -816,13 +810,7 @@ eso_halt_input(void *hdl)
 	DMA37MD_WRITE | DMA37MD_DEMAND);
 
 	sc->sc_rintr = NULL;
-	mutex_exit(&sc->sc_lock);
 	error = cv_timedwait_sig(&sc->sc_rcv, &sc->sc_intr_lock, sc->sc_rdrain);
-	if (!mutex_tryenter(&sc->sc_lock)) {
-		mutex_spin_exit(&sc->sc_intr_lock);
-		mutex_enter(&sc->sc_lock);
-		mutex_spin_enter(&sc->sc_intr_lock);
-	}
 
 	/* Shut down DMA completely. */
 	eso_write_ctlreg(sc, ESO_CTLREG_A1C2,



CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 04:45:34 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: eso.c esoreg.h

Log Message:
Adapt to audio2.
- Select a few typical frequencies which doesn't have rounding error
  instead of whole range.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.2 src/sys/dev/pci/eso.c
cvs rdiff -u -r1.8 -r1.8.168.1 src/sys/dev/pci/esoreg.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/dev/pci/eso.c
diff -u src/sys/dev/pci/eso.c:1.69.2.1 src/sys/dev/pci/eso.c:1.69.2.2
--- src/sys/dev/pci/eso.c:1.69.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/eso.c	Sun Apr 28 04:45:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: eso.c,v 1.69.2.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: eso.c,v 1.69.2.2 2019/04/28 04:45:34 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.69.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.69.2.2 2019/04/28 04:45:34 isaki Exp $");
 
 #include "mpu.h"
 
@@ -80,9 +80,6 @@ __KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.69
 #include 
 #include 
 
-#include 
-#include 
-
 #include 
 #include 
 #include 
@@ -131,10 +128,10 @@ CFATTACH_DECL_NEW(eso, sizeof (struct es
 static int eso_intr(void *);
 
 /* MI audio layer interface */
-static int	eso_query_encoding(void *, struct audio_encoding *);
-static int	eso_set_params(void *, int, int, audio_params_t *,
-		audio_params_t *, stream_filter_list_t *,
-		stream_filter_list_t *);
+static int	eso_query_format(void *, audio_format_query_t *);
+static int	eso_set_format(void *, int,
+		const audio_params_t *, const audio_params_t *,
+		audio_filter_reg_t *, audio_filter_reg_t *);
 static int	eso_round_blocksize(void *, int, int, const audio_params_t *);
 static int	eso_halt_output(void *);
 static int	eso_halt_input(void *);
@@ -145,7 +142,6 @@ static int	eso_query_devinfo(void *, mix
 static void *	eso_allocm(void *, int, size_t);
 static void	eso_freem(void *, void *, size_t);
 static size_t	eso_round_buffersize(void *, int, size_t);
-static paddr_t	eso_mappage(void *, void *, off_t, int);
 static int	eso_get_props(void *);
 static int	eso_trigger_output(void *, void *, void *, int,
 		void (*)(void *), void *, const audio_params_t *);
@@ -154,8 +150,8 @@ static int	eso_trigger_input(void *, voi
 static void	eso_get_locks(void *, kmutex_t **, kmutex_t **);
 
 static const struct audio_hw_if eso_hw_if = {
-	.query_encoding		= eso_query_encoding,
-	.set_params		= eso_set_params,
+	.query_format		= eso_query_format,
+	.set_format		= eso_set_format,
 	.round_blocksize	= eso_round_blocksize,
 	.halt_output		= eso_halt_output,
 	.halt_input		= eso_halt_input,
@@ -166,7 +162,6 @@ static const struct audio_hw_if eso_hw_i
 	.allocm			= eso_allocm,
 	.freem			= eso_freem,
 	.round_buffersize	= eso_round_buffersize,
-	.mappage		= eso_mappage,
 	.get_props		= eso_get_props,
 	.trigger_output		= eso_trigger_output,
 	.trigger_input		= eso_trigger_input,
@@ -179,28 +174,23 @@ static const char * const eso_rev2model[
 	"ES1946 Revision E"
 };
 
-#define ESO_NFORMATS	8
-#define ESO_FORMAT(enc, prec, ch, chmask) \
-	{ \
-		.mode		= AUMODE_PLAY | AUMODE_RECORD, \
-		.encoding	= (enc), \
-		.validbits	= (prec), \
-		.precision	= (prec), \
-		.channels	= (ch), \
-		.channel_mask	= (chmask), \
-		.frequency_type	= 0, \
-		.frequency	= { ESO_MINRATE, ESO_MAXRATE }, \
-	}
-static const struct audio_format eso_formats[ESO_NFORMATS] = {
-	ESO_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	ESO_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	ESO_FORMAT(AUDIO_ENCODING_ULINEAR_LE, 16, 2, AUFMT_STEREO),
-	ESO_FORMAT(AUDIO_ENCODING_ULINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	ESO_FORMAT(AUDIO_ENCODING_SLINEAR_LE,  8, 2, AUFMT_STEREO),
-	ESO_FORMAT(AUDIO_ENCODING_SLINEAR_LE,  8, 1, AUFMT_MONAURAL),
-	ESO_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-	ESO_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
+/*
+ * XXX The HW actually supports more frequencies but I select a few
+ * typical frequencies which does not include rounding error.
+ */
+static const struct audio_format eso_formats[] = {
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 4,
+		.frequency	= { 8000, 22050, 44100, 48000 },
+	},
 };
+#define ESO_NFORMATS	__arraycount(eso_formats)
 
 
 /*
@@ -700,76 +690,21 @@ eso_reset(struct eso_softc *sc)
 }
 
 static int
-eso_query_encoding(void *hdl, struct audio_encoding *fp)
+eso_query_format(void *hdl, audio_format_query_t *afp)
 {
 
-	switch (fp->index) {
-	case 0:
-		strcpy(fp->name, AudioEulinear);
-		fp->encoding = AUDIO_ENCODING_ULINEAR;
-		fp->precision = 8;
-		fp->f

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 03:33:26 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: esm.c esmvar.h

Log Message:
Adapt to audio2.
- Recording seems a bit tricky so I left it untouched.
  (It should work on audio2 as well if it works on -current/-8.)


To generate a diff of this commit:
cvs rdiff -u -r1.61.2.1 -r1.61.2.2 src/sys/dev/pci/esm.c
cvs rdiff -u -r1.18 -r1.18.54.1 src/sys/dev/pci/esmvar.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/dev/pci/esm.c
diff -u src/sys/dev/pci/esm.c:1.61.2.1 src/sys/dev/pci/esm.c:1.61.2.2
--- src/sys/dev/pci/esm.c:1.61.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/esm.c	Sun Apr 28 03:33:26 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: esm.c,v 1.61.2.1 2019/04/21 05:11:22 isaki Exp $  */
+/*  $NetBSD: esm.c,v 1.61.2.2 2019/04/28 03:33:26 isaki Exp $  */
 
 /*-
  * Copyright (c) 2002, 2003 Matt Fredette
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.61.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.61.2.2 2019/04/28 03:33:26 isaki Exp $");
 
 #include 
 #include 
@@ -77,8 +77,6 @@ __KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.61
 #include 
 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -160,8 +158,8 @@ CFATTACH_DECL2_NEW(esm, sizeof(struct es
 esm_match, esm_attach, esm_detach, NULL, NULL, esm_childdet);
 
 const struct audio_hw_if esm_hw_if = {
-	.query_encoding		= esm_query_encoding,
-	.set_params		= esm_set_params,
+	.query_format		= esm_query_format,
+	.set_format		= esm_set_format,
 	.round_blocksize	= esm_round_blocksize,
 	.init_output		= esm_init_output,
 	.init_input		= esm_init_input,
@@ -174,7 +172,6 @@ const struct audio_hw_if esm_hw_if = {
 	.allocm			= esm_malloc,
 	.freem			= esm_free,
 	.round_buffersize	= esm_round_buffersize,
-	.mappage		= esm_mappage,
 	.get_props		= esm_get_props,
 	.trigger_output		= esm_trigger_output,
 	.trigger_input		= esm_trigger_input,
@@ -187,23 +184,6 @@ struct audio_device esm_device = {
 	"esm"
 };
 
-#define MAESTRO_NENCODINGS 8
-static audio_encoding_t esm_encoding[MAESTRO_NENCODINGS] = {
-	{ 0, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 0 },
-	{ 1, AudioEmulaw, AUDIO_ENCODING_ULAW, 8,
-		AUDIO_ENCODINGFLAG_EMULATED },
-	{ 2, AudioEalaw, AUDIO_ENCODING_ALAW, 8, AUDIO_ENCODINGFLAG_EMULATED },
-	{ 3, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, 0 },
-	{ 4, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 0 },
-	{ 5, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16,
-		AUDIO_ENCODINGFLAG_EMULATED },
-	{ 6, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16,
-		AUDIO_ENCODINGFLAG_EMULATED },
-	{ 7, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16,
-		AUDIO_ENCODINGFLAG_EMULATED },
-};
-
-#define ESM_NFORMATS	4
 #define ESM_FORMAT(enc, prec, ch, chmask) \
 	{ \
 		.mode		= AUMODE_PLAY | AUMODE_RECORD, \
@@ -215,12 +195,17 @@ static audio_encoding_t esm_encoding[MAE
 		.frequency_type	= 0, \
 		.frequency	= { 4000, 48000 }, \
 	}
-static const struct audio_format esm_formats[ESM_NFORMATS] = {
+/*
+ * XXX Recodring on 16bit/stereo seems a bit tricky so I left all
+ * combination 8/16bit and mono/stereo.
+ */
+static const struct audio_format esm_formats[] = {
 	ESM_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
 	ESM_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
 	ESM_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
 	ESM_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
 };
+#define ESM_NFORMATS	__arraycount(esm_formats)
 
 static const struct esm_quirks esm_quirks[] = {
 	/* COMPAL 38W2 OEM Notebook, e.g. Dell INSPIRON 5000e */
@@ -1208,66 +1193,28 @@ esm_round_blocksize(void *sc, int blk, i
 }
 
 int
-esm_query_encoding(void *sc, struct audio_encoding *fp)
+esm_query_format(void *sc, audio_format_query_t *afp)
 {
 
-	DPRINTF(ESM_DEBUG_PARAM,
-	("esm_query_encoding(%p, %d)\n", sc, fp->index));
-
-	if (fp->index < 0 || fp->index >= MAESTRO_NENCODINGS)
-		return EINVAL;
-
-	*fp = esm_encoding[fp->index];
-	return 0;
+	return audio_query_format(esm_formats, ESM_NFORMATS, afp);
 }
 
 int
-esm_set_params(void *sc, int setmode, int usemode,
-	audio_params_t *play, audio_params_t *rec,
-	stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+esm_set_format(void *sc, int setmode,
+	const audio_params_t *play, const audio_params_t *rec,
+	audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
 	struct esm_softc *ess;
-	audio_params_t *p;
-	const audio_params_t *hw_play, *hw_rec;
-	stream_filter_list_t *fil;
-	int mode, i;
 
 	DPRINTF(ESM_DEBUG_PARAM,
-	("esm_set_params(%p, 0x%x, 0x%x, %p, %p)\n",
-	sc, setmode, usemode, play, rec));
+	("%s(%p, 0x%x, %p, %p)\n", __func__,
+	sc, setmode, play, rec));
 	ess = sc;
-	hw_play = NULL;
-	hw_rec = NULL;
-	for (mode = AUMODE_RECORD; mode != -1;
-	 mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
-		if ((setmod

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 03:00:21 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: esa.c

Log Message:
Adapt to audio2.
- Fix wrong round_blocksize() calculation. ~0x20 -> -0x20.


To generate a diff of this commit:
cvs rdiff -u -r1.63.2.1 -r1.63.2.2 src/sys/dev/pci/esa.c

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

Modified files:

Index: src/sys/dev/pci/esa.c
diff -u src/sys/dev/pci/esa.c:1.63.2.1 src/sys/dev/pci/esa.c:1.63.2.2
--- src/sys/dev/pci/esa.c:1.63.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/esa.c	Sun Apr 28 03:00:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: esa.c,v 1.63.2.1 2019/04/21 05:11:22 isaki Exp $ */
+/* $NetBSD: esa.c,v 1.63.2.2 2019/04/28 03:00:21 isaki Exp $ */
 
 /*
  * Copyright (c) 2001-2008 Jared D. McNeill 
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.63.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.63.2.2 2019/04/28 03:00:21 isaki Exp $");
 
 #include 
 #include 
@@ -56,8 +56,6 @@ __KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.63
 #include 
 
 #include 
-#include 
-#include 
 
 #include 
 #include 
@@ -104,10 +102,12 @@ static int		esa_detach(device_t, int);
 static void		esa_childdet(device_t, device_t);
 
 /* audio(9) functions */
-static int		esa_query_encoding(void *, struct audio_encoding *);
-static int		esa_set_params(void *, int, int, audio_params_t *,
-   audio_params_t *, stream_filter_list_t *,
-   stream_filter_list_t *);
+static int		esa_query_format(void *, audio_format_query_t *);
+static int		esa_set_format(void *, int,
+   const audio_params_t *,
+   const audio_params_t *,
+   audio_filter_reg_t *,
+   audio_filter_reg_t *);
 static int		esa_round_blocksize(void *, int, int,
 	const audio_params_t *);
 static int		esa_commit_settings(void *);
@@ -119,7 +119,6 @@ static int		esa_query_devinfo(void *, mi
 static void *		esa_malloc(void *, int, size_t);
 static void		esa_free(void *, void *, size_t);
 static int		esa_getdev(void *, struct audio_device *);
-static size_t		esa_round_buffersize(void *, int, size_t);
 static int		esa_get_props(void *);
 static int		esa_trigger_output(void *, void *, void *, int,
 	   void (*)(void *), void *,
@@ -166,45 +165,23 @@ static bool		esa_suspend(device_t, const
 static bool		esa_resume(device_t, const pmf_qual_t *);
 
 
-#define ESA_NENCODINGS 8
-static audio_encoding_t esa_encoding[ESA_NENCODINGS] = {
-	{ 0, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 0 },
-	{ 1, AudioEmulaw, AUDIO_ENCODING_ULAW, 8,
-		AUDIO_ENCODINGFLAG_EMULATED },
-	{ 2, AudioEalaw, AUDIO_ENCODING_ALAW, 8, AUDIO_ENCODINGFLAG_EMULATED },
-	{ 3, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8,
-		AUDIO_ENCODINGFLAG_EMULATED }, /* XXX: Are you sure? */
-	{ 4, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 0 },
-	{ 5, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16,
-		AUDIO_ENCODINGFLAG_EMULATED },
-	{ 6, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16,
-		AUDIO_ENCODINGFLAG_EMULATED },
-	{ 7, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16,
-		AUDIO_ENCODINGFLAG_EMULATED }
-};
-
-#define ESA_NFORMATS	4
-#define ESA_FORMAT(enc, prec, ch, chmask) \
-	{ \
-		.mode		= AUMODE_PLAY | AUMODE_RECORD, \
-		.encoding	= (enc), \
-		.validbits	= (prec), \
-		.precision	= (prec), \
-		.channels	= (ch), \
-		.channel_mask	= (chmask), \
-		.frequency_type	= 0, \
-		.frequency	= { ESA_MINRATE, ESA_MAXRATE }, \
-	}
-static const struct audio_format esa_formats[ESA_NFORMATS] = {
-	ESA_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	ESA_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	ESA_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-	ESA_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
+static const struct audio_format esa_formats[] = {
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 0,
+		.frequency	= { ESA_MINRATE, ESA_MAXRATE },
+	},
 };
+#define ESA_NFORMATS	__arraycount(esa_formats)
 
 static const struct audio_hw_if esa_hw_if = {
-	.query_encoding		= esa_query_encoding,
-	.set_params		= esa_set_params,
+	.query_format		= esa_query_format,
+	.set_format		= esa_set_format,
 	.round_blocksize	= esa_round_blocksize,
 	.commit_settings	= esa_commit_settings,
 	.halt_output		= esa_halt_output,
@@ -215,7 +192,6 @@ static const struct audio_hw_if esa_hw_i
 	.query_devinfo		= esa_query_devinfo,
 	.allocm			= esa_malloc,
 	.freem			= esa_free,
-	.round_buffersize	= esa_round_buffersize,
 	.mappage		= esa_mappage,
 	.get_props		= esa_get_props,
 	.trigger_output		= esa_trigger_output,
@@ -231,62 +207,24 @@ CFATTACH_DECL2_NEW(esa, sizeof(struct es
  */
 
 static int
-esa_query_encoding(void *hdl, struct audio_encoding *ae)
+esa_query_format(void *hdl, audio_forma

CVS commit: [isaki-audio2] src/sys/dev/pci

2019-04-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 02:19:35 UTC 2019

Modified Files:
src/sys/dev/pci [isaki-audio2]: cmpci.c

Log Message:
Adapt to audio2.


To generate a diff of this commit:
cvs rdiff -u -r1.53.2.1 -r1.53.2.2 src/sys/dev/pci/cmpci.c

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

Modified files:

Index: src/sys/dev/pci/cmpci.c
diff -u src/sys/dev/pci/cmpci.c:1.53.2.1 src/sys/dev/pci/cmpci.c:1.53.2.2
--- src/sys/dev/pci/cmpci.c:1.53.2.1	Sun Apr 21 05:11:22 2019
+++ src/sys/dev/pci/cmpci.c	Sun Apr 28 02:19:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmpci.c,v 1.53.2.1 2019/04/21 05:11:22 isaki Exp $	*/
+/*	$NetBSD: cmpci.c,v 1.53.2.2 2019/04/28 02:19:35 isaki Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cmpci.c,v 1.53.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cmpci.c,v 1.53.2.2 2019/04/28 02:19:35 isaki Exp $");
 
 #if defined(AUDIO_DEBUG) || defined(DEBUG)
 #define DPRINTF(x) if (cmpcidebug) printf x
@@ -68,8 +68,6 @@ int cmpcidebug = 0;
 #include 
 #include 
 
-#include 
-#include 
 #include 
 #include 
 
@@ -128,9 +126,10 @@ static struct cmpci_dmanode * cmpci_find
 /*
  * interface to machine independent layer
  */
-static int cmpci_query_encoding(void *, struct audio_encoding *);
-static int cmpci_set_params(void *, int, int, audio_params_t *,
-	audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+static int cmpci_query_format(void *, audio_format_query_t *);
+static int cmpci_set_format(void *, int,
+const audio_params_t *, const audio_params_t *,
+audio_filter_reg_t *, audio_filter_reg_t *);
 static int cmpci_round_blocksize(void *, int, int, const audio_params_t *);
 static int cmpci_halt_output(void *);
 static int cmpci_halt_input(void *);
@@ -141,7 +140,6 @@ static int cmpci_query_devinfo(void *, m
 static void *cmpci_allocm(void *, int, size_t);
 static void cmpci_freem(void *, void *, size_t);
 static size_t cmpci_round_buffersize(void *, int, size_t);
-static paddr_t cmpci_mappage(void *, void *, off_t, int);
 static int cmpci_get_props(void *);
 static int cmpci_trigger_output(void *, void *, void *, int,
 	void (*)(void *), void *, const audio_params_t *);
@@ -150,8 +148,8 @@ static int cmpci_trigger_input(void *, v
 static void cmpci_get_locks(void *, kmutex_t **, kmutex_t **);
 
 static const struct audio_hw_if cmpci_hw_if = {
-	.query_encoding		= cmpci_query_encoding,
-	.set_params		= cmpci_set_params,
+	.query_format		= cmpci_query_format,
+	.set_format		= cmpci_set_format,
 	.round_blocksize	= cmpci_round_blocksize,
 	.halt_output		= cmpci_halt_output,
 	.halt_input		= cmpci_halt_input,
@@ -162,31 +160,26 @@ static const struct audio_hw_if cmpci_hw
 	.allocm			= cmpci_allocm,
 	.freem			= cmpci_freem,
 	.round_buffersize	= cmpci_round_buffersize,
-	.mappage		= cmpci_mappage,
 	.get_props		= cmpci_get_props,
 	.trigger_output		= cmpci_trigger_output,
 	.trigger_input		= cmpci_trigger_input,
 	.get_locks		= cmpci_get_locks,
 };
 
-#define CMPCI_NFORMATS	4
-#define CMPCI_FORMAT(enc, prec, ch, chmask) \
-	{ \
-		.mode		= AUMODE_PLAY | AUMODE_RECORD, \
-		.encoding	= (enc), \
-		.validbits	= (prec), \
-		.precision	= (prec), \
-		.channels	= (ch), \
-		.channel_mask	= (chmask), \
-		.frequency_type	= 0, \
-		.frequency	= { 5512, 48000 }, \
-	}
-static const struct audio_format cmpci_formats[CMPCI_NFORMATS] = {
-	CMPCI_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 2, AUFMT_STEREO),
-	CMPCI_FORMAT(AUDIO_ENCODING_SLINEAR_LE, 16, 1, AUFMT_MONAURAL),
-	CMPCI_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 2, AUFMT_STEREO),
-	CMPCI_FORMAT(AUDIO_ENCODING_ULINEAR_LE,  8, 1, AUFMT_MONAURAL),
+static const struct audio_format cmpci_formats[] = {
+	{
+		.mode		= AUMODE_PLAY | AUMODE_RECORD,
+		.encoding	= AUDIO_ENCODING_SLINEAR_LE,
+		.validbits	= 16,
+		.precision	= 16,
+		.channels	= 2,
+		.channel_mask	= AUFMT_STEREO,
+		.frequency_type	= 8,
+		.frequency	=
+		{ 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000 },
+	},
 };
+#define CMPCI_NFORMATS __arraycount(cmpci_formats)
 
 
 /*
@@ -330,8 +323,7 @@ cmpci_rate_to_index(int rate)
 	int i;
 
 	for (i = 0; i < CMPCI_REG_NUMRATE - 1; i++)
-		if (rate <=
-		(cmpci_rate_table[i].rate+cmpci_rate_table[i+1].rate) / 2)
+		if (rate == cmpci_rate_table[i].rate)
 			return i;
 	return i;  /* 48000 */
 }
@@ -572,69 +564,16 @@ cmpci_intr(void *handle)
 }
 
 static int
-cmpci_query_encoding(void *handle, struct audio_encoding *fp)
+cmpci_query_format(void *handle, audio_format_query_t *afp)
 {
 
-	switch (fp->index) {
-	case 0:
-		strcpy(fp->name, AudioEulinear);
-		fp->encoding = AUDIO_ENCODING_ULINEAR;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-		break;
-	case 1:
-		strcpy(fp->name, AudioEmulaw);
-		fp->encoding = AUDIO_ENCODING_ULAW;
-		fp->precision = 8;
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED

<    1   2   3   4   5   >