Module Name: src
Committed By: isaki
Date: Sun Apr 21 06:00:00 UTC 2019
Modified Files:
src/sys/arch/amiga/dev [isaki-audio2]: toccata.c
src/sys/arch/prep/isa [isaki-audio2]: paud_isa.c
src/sys/dev/ebus [isaki-audio2]: cs4231_ebus.c
src/sys/dev/ic [isaki-audio2]: ad1848.c ad1848var.h interwave.c
interwavevar.h
src/sys/dev/isa [isaki-audio2]: gus.c wss.c ym.c
src/sys/dev/isapnp [isaki-audio2]: gus_isapnp.c
src/sys/dev/sbus [isaki-audio2]: cs4231_sbus.c
Log Message:
Adapt ad1848/cs4231 families to audio2.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.2.1 src/sys/arch/amiga/dev/toccata.c
cvs rdiff -u -r1.17 -r1.17.2.1 src/sys/arch/prep/isa/paud_isa.c
cvs rdiff -u -r1.38 -r1.38.2.1 src/sys/dev/ebus/cs4231_ebus.c
cvs rdiff -u -r1.31 -r1.31.54.1 src/sys/dev/ic/ad1848.c
cvs rdiff -u -r1.18 -r1.18.54.1 src/sys/dev/ic/ad1848var.h
cvs rdiff -u -r1.40 -r1.40.2.1 src/sys/dev/ic/interwave.c
cvs rdiff -u -r1.18 -r1.18.42.1 src/sys/dev/ic/interwavevar.h
cvs rdiff -u -r1.115 -r1.115.2.1 src/sys/dev/isa/gus.c
cvs rdiff -u -r1.72 -r1.72.2.1 src/sys/dev/isa/wss.c
cvs rdiff -u -r1.45 -r1.45.2.1 src/sys/dev/isa/ym.c
cvs rdiff -u -r1.39 -r1.39.2.1 src/sys/dev/isapnp/gus_isapnp.c
cvs rdiff -u -r1.51 -r1.51.2.1 src/sys/dev/sbus/cs4231_sbus.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 src/sys/arch/amiga/dev/toccata.c:1.18.2.1
--- src/sys/arch/amiga/dev/toccata.c:1.18 Sat Mar 16 12:09:56 2019
+++ src/sys/arch/amiga/dev/toccata.c Sun Apr 21 05:59:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: toccata.c,v 1.18 2019/03/16 12:09:56 isaki Exp $ */
+/* $NetBSD: toccata.c,v 1.18.2.1 2019/04/21 05:59:59 isaki Exp $ */
/*-
* Copyright (c) 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: toccata.c,v 1.18 2019/03/16 12:09:56 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: toccata.c,v 1.18.2.1 2019/04/21 05:59:59 isaki Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -185,8 +185,8 @@ const struct audio_hw_if audiocs_hw_if =
* sample data, otherwise up to 1024.
*/
.drain = NULL,
- .query_encoding = ad1848_query_encoding,
- .set_params = ad1848_set_params,
+ .query_format = ad1848_query_format,
+ .set_format = ad1848_set_format,
.round_blocksize = toccata_round_blocksize,
.commit_settings = ad1848_commit_settings,
.init_output = NULL, /* XXX need this to prefill? */
Index: src/sys/arch/prep/isa/paud_isa.c
diff -u src/sys/arch/prep/isa/paud_isa.c:1.17 src/sys/arch/prep/isa/paud_isa.c:1.17.2.1
--- src/sys/arch/prep/isa/paud_isa.c:1.17 Sat Mar 16 12:09:57 2019
+++ src/sys/arch/prep/isa/paud_isa.c Sun Apr 21 05:59:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: paud_isa.c,v 1.17 2019/03/16 12:09:57 isaki Exp $ */
+/* $NetBSD: paud_isa.c,v 1.17.2.1 2019/04/21 05:59:59 isaki Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: paud_isa.c,v 1.17 2019/03/16 12:09:57 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: paud_isa.c,v 1.17.2.1 2019/04/21 05:59:59 isaki Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -96,8 +96,8 @@ static int paud_query_devinfo(void *, mi
static const struct audio_hw_if paud_hw_if = {
.open = ad1848_isa_open,
.close = ad1848_isa_close,
- .query_encoding = ad1848_query_encoding,
- .set_params = ad1848_set_params,
+ .query_format = ad1848_query_format,
+ .set_format = ad1848_set_format,
.round_blocksize = ad1848_round_blocksize,
.commit_settings = ad1848_commit_settings,
.halt_output = ad1848_isa_halt_output,
@@ -109,7 +109,6 @@ static const struct audio_hw_if paud_hw_
.allocm = ad1848_isa_malloc,
.freem = ad1848_isa_free,
.round_buffersize = ad1848_isa_round_buffersize,
- .mappage = ad1848_isa_mappage,
.get_props = ad1848_isa_get_props,
.trigger_output = ad1848_isa_trigger_output,
.trigger_input = ad1848_isa_trigger_input,
Index: src/sys/dev/ebus/cs4231_ebus.c
diff -u src/sys/dev/ebus/cs4231_ebus.c:1.38 src/sys/dev/ebus/cs4231_ebus.c:1.38.2.1
--- src/sys/dev/ebus/cs4231_ebus.c:1.38 Sat Mar 16 12:09:57 2019
+++ src/sys/dev/ebus/cs4231_ebus.c Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cs4231_ebus.c,v 1.38 2019/03/16 12:09:57 isaki Exp $ */
+/* $NetBSD: cs4231_ebus.c,v 1.38.2.1 2019/04/21 06:00:00 isaki Exp $ */
/*
* Copyright (c) 2002 Valeriy E. Ushakov
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cs4231_ebus.c,v 1.38 2019/03/16 12:09:57 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cs4231_ebus.c,v 1.38.2.1 2019/04/21 06:00:00 isaki Exp $");
#ifdef _KERNEL_OPT
#include "opt_sparc_arch.h"
@@ -98,8 +98,8 @@ static int cs4231_ebus_halt_input(void *
const struct audio_hw_if audiocs_ebus_hw_if = {
.open = cs4231_open,
.close = cs4231_close,
- .query_encoding = ad1848_query_encoding,
- .set_params = ad1848_set_params,
+ .query_format = ad1848_query_format,
+ .set_format = ad1848_set_format,
.round_blocksize = cs4231_ebus_round_blocksize,
.commit_settings = ad1848_commit_settings,
.halt_output = cs4231_ebus_halt_output,
Index: src/sys/dev/ic/ad1848.c
diff -u src/sys/dev/ic/ad1848.c:1.31 src/sys/dev/ic/ad1848.c:1.31.54.1
--- src/sys/dev/ic/ad1848.c:1.31 Wed Nov 23 23:07:32 2011
+++ src/sys/dev/ic/ad1848.c Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ad1848.c,v 1.31 2011/11/23 23:07:32 jmcneill Exp $ */
+/* $NetBSD: ad1848.c,v 1.31.54.1 2019/04/21 06:00:00 isaki Exp $ */
/*-
* Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ad1848.c,v 1.31 2011/11/23 23:07:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ad1848.c,v 1.31.54.1 2019/04/21 06:00:00 isaki Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -110,9 +110,7 @@ __KERNEL_RCSID(0, "$NetBSD: ad1848.c,v 1
#include <sys/bus.h>
#include <sys/audioio.h>
-
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/ic/ad1848reg.h>
#include <dev/ic/cs4231reg.h>
@@ -139,6 +137,21 @@ void ad1848_dump_regs(struct ad1848_soft
#define DPRINTF(x)
#endif
+/* The HW supports more frequencies but I chose several major ones. */
+static const struct audio_format ad1848_formats[] = {
+ {
+ .mode = AUMODE_PLAY | AUMODE_RECORD,
+ .encoding = AUDIO_ENCODING_SLINEAR_LE,
+ .validbits = 16,
+ .precision = 16,
+ .channels = 2,
+ .channel_mask = AUFMT_STEREO,
+ .frequency_type = 6,
+ .frequency = { 8000, 11025, 16000, 22050, 44100, 48000 },
+ },
+};
+#define AD1848_NFORMATS __arraycount(ad1848_formats)
+
/*
* Initial values for the indirect registers of CS4248/AD1848.
*/
@@ -777,203 +790,38 @@ ad1848_mixer_set_port(struct ad1848_soft
}
int
-ad1848_query_encoding(void *addr, struct audio_encoding *fp)
+ad1848_query_format(void *addr, audio_format_query_t *afp)
{
- struct ad1848_softc *sc;
-
- sc = addr;
- switch (fp->index) {
- case 0:
- strcpy(fp->name, AudioEmulaw);
- fp->encoding = AUDIO_ENCODING_ULAW;
- fp->precision = 8;
- fp->flags = 0;
- break;
- case 1:
- strcpy(fp->name, AudioEalaw);
- fp->encoding = AUDIO_ENCODING_ALAW;
- fp->precision = 8;
- fp->flags = 0;
- break;
- case 2:
- strcpy(fp->name, AudioEslinear_le);
- fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
- fp->precision = 16;
- fp->flags = 0;
- break;
- case 3:
- strcpy(fp->name, AudioEulinear);
- fp->encoding = AUDIO_ENCODING_ULINEAR;
- fp->precision = 8;
- fp->flags = 0;
- break;
-
- case 4: /* only on CS4231 */
- strcpy(fp->name, AudioEslinear_be);
- fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
- fp->precision = 16;
- fp->flags = sc->mode == 1
-#if AD1845_HACK
- || sc->is_ad1845
-#endif
- ? AUDIO_ENCODINGFLAG_EMULATED : 0;
- break;
- /* emulate some modes */
- case 5:
- strcpy(fp->name, AudioEslinear);
- fp->encoding = AUDIO_ENCODING_SLINEAR;
- fp->precision = 8;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- case 6:
- strcpy(fp->name, AudioEulinear_le);
- fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
- fp->precision = 16;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- case 7:
- strcpy(fp->name, AudioEulinear_be);
- fp->encoding = AUDIO_ENCODING_ULINEAR_BE;
- fp->precision = 16;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
-
- case 8: /* only on CS4231 */
- if (sc->mode == 1 || sc->is_ad1845)
- return EINVAL;
- strcpy(fp->name, AudioEadpcm);
- fp->encoding = AUDIO_ENCODING_ADPCM;
- fp->precision = 4;
- fp->flags = 0;
- break;
- default:
- return EINVAL;
- /*NOTREACHED*/
- }
- return 0;
+ return audio_query_format(ad1848_formats, AD1848_NFORMATS, afp);
}
int
-ad1848_set_params(void *addr, int setmode, int usemode,
- audio_params_t *p, audio_params_t *r, stream_filter_list_t *pfil,
- stream_filter_list_t *rfil)
+ad1848_set_format(void *addr, int setmode,
+ const audio_params_t *p, const audio_params_t *r,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
- audio_params_t phw, rhw;
struct ad1848_softc *sc;
- int error, bits, enc;
- stream_filter_factory_t *pswcode;
- stream_filter_factory_t *rswcode;
+ int rate;
+ int error;
- DPRINTF(("ad1848_set_params: %u %u %u %u\n",
- p->encoding, p->precision, p->channels, p->sample_rate));
+ /* *p and *r are the identical because !AUDIO_PROP_INDEPENDENT. */
+ DPRINTF(("%s: %u %u %u %u\n", __func__,
+ p->encoding, p->precision, p->channels, p->sample_rate));
sc = addr;
- enc = p->encoding;
- pswcode = rswcode = 0;
- phw = *p;
- rhw = *r;
- switch (enc) {
- case AUDIO_ENCODING_SLINEAR_LE:
- if (p->precision == 8) {
- enc = AUDIO_ENCODING_ULINEAR_LE;
- phw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- rhw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- pswcode = rswcode = change_sign8;
- }
- break;
- case AUDIO_ENCODING_SLINEAR_BE:
- if (p->precision == 16 && (sc->mode == 1
-#if AD1845_HACK
- || sc->is_ad1845
-#endif
- )) {
- enc = AUDIO_ENCODING_SLINEAR_LE;
- phw.encoding = AUDIO_ENCODING_SLINEAR_LE;
- rhw.encoding = AUDIO_ENCODING_SLINEAR_LE;
- pswcode = rswcode = swap_bytes;
- }
- break;
- case AUDIO_ENCODING_ULINEAR_LE:
- if (p->precision == 16) {
- enc = AUDIO_ENCODING_SLINEAR_LE;
- phw.encoding = AUDIO_ENCODING_SLINEAR_LE;
- rhw.encoding = AUDIO_ENCODING_SLINEAR_LE;
- pswcode = rswcode = change_sign16;
- }
- break;
- case AUDIO_ENCODING_ULINEAR_BE:
- if (p->precision == 16) {
- if (sc->mode == 1
-#if AD1845_HACK
- || sc->is_ad1845
-#endif
- ) {
- enc = AUDIO_ENCODING_SLINEAR_LE;
- phw.encoding = AUDIO_ENCODING_SLINEAR_LE;
- rhw.encoding = AUDIO_ENCODING_SLINEAR_LE;
- pswcode = swap_bytes_change_sign16;
- rswcode = swap_bytes_change_sign16;
- } else {
- enc = AUDIO_ENCODING_SLINEAR_BE;
- phw.encoding = AUDIO_ENCODING_SLINEAR_BE;
- rhw.encoding = AUDIO_ENCODING_SLINEAR_BE;
- pswcode = rswcode = change_sign16;
- }
- }
- break;
- }
- switch (enc) {
- case AUDIO_ENCODING_ULAW:
- bits = FMT_ULAW >> 5;
- break;
- case AUDIO_ENCODING_ALAW:
- bits = FMT_ALAW >> 5;
- break;
- case AUDIO_ENCODING_ADPCM:
- bits = FMT_ADPCM >> 5;
- break;
- case AUDIO_ENCODING_SLINEAR_LE:
- if (p->precision == 16)
- bits = FMT_TWOS_COMP >> 5;
- else
- return EINVAL;
- break;
- case AUDIO_ENCODING_SLINEAR_BE:
- if (p->precision == 16)
- bits = FMT_TWOS_COMP_BE >> 5;
- else
- return EINVAL;
- break;
- case AUDIO_ENCODING_ULINEAR_LE:
- if (p->precision == 8)
- bits = FMT_PCM8 >> 5;
- else
- return EINVAL;
- break;
- default:
- return EINVAL;
- }
- if (p->channels < 1 || p->channels > 2)
- return EINVAL;
-
- error = ad1848_set_speed(sc, &p->sample_rate);
+ rate = p->sample_rate;
+ error = ad1848_set_speed(sc, &rate);
if (error)
return error;
- phw.sample_rate = p->sample_rate;
-
- if (pswcode != NULL)
- pfil->append(pfil, pswcode, &phw);
- if (rswcode != NULL)
- rfil->append(rfil, rswcode, &rhw);
- sc->format_bits = bits;
+ sc->format_bits = FMT_TWOS_COMP >> 5;
sc->channels = p->channels;
sc->precision = p->precision;
sc->need_commit = 1;
- DPRINTF(("ad1848_set_params succeeded, bits=%x\n", bits));
+ DPRINTF(("%s succeeded\n", __func__));
return 0;
}
Index: src/sys/dev/ic/ad1848var.h
diff -u src/sys/dev/ic/ad1848var.h:1.18 src/sys/dev/ic/ad1848var.h:1.18.54.1
--- src/sys/dev/ic/ad1848var.h:1.18 Wed Nov 23 23:07:32 2011
+++ src/sys/dev/ic/ad1848var.h Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ad1848var.h,v 1.18 2011/11/23 23:07:32 jmcneill Exp $ */
+/* $NetBSD: ad1848var.h,v 1.18.54.1 2019/04/21 06:00:00 isaki Exp $ */
/*-
* Copyright (c) 1999, 2008 The NetBSD Foundation, Inc.
@@ -172,10 +172,10 @@ int ad1848_mixer_set_port(struct ad1848_
int, mixer_ctrl_t *);
int ad1848_set_speed(struct ad1848_softc *, u_int *);
void ad1848_mute_wave_output(struct ad1848_softc *, int, int);
-int ad1848_query_encoding(void *, struct audio_encoding *);
-int ad1848_set_params(void *, int, int, audio_params_t *,
- audio_params_t *, stream_filter_list_t *,
- stream_filter_list_t *);
+int ad1848_query_format(void *, audio_format_query_t *);
+int ad1848_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
int ad1848_round_blocksize(void *, int, int, const audio_params_t *);
int ad1848_commit_settings(void *);
int ad1848_set_rec_port(struct ad1848_softc *, int);
Index: src/sys/dev/ic/interwave.c
diff -u src/sys/dev/ic/interwave.c:1.40 src/sys/dev/ic/interwave.c:1.40.2.1
--- src/sys/dev/ic/interwave.c:1.40 Sun Feb 3 11:15:45 2019
+++ src/sys/dev/ic/interwave.c Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: interwave.c,v 1.40 2019/02/03 11:15:45 mrg Exp $ */
+/* $NetBSD: interwave.c,v 1.40.2.1 2019/04/21 06:00:00 isaki Exp $ */
/*
* Copyright (c) 1997, 1999, 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.40 2019/02/03 11:15:45 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.40.2.1 2019/04/21 06:00:00 isaki Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -49,7 +49,6 @@ __KERNEL_RCSID(0, "$NetBSD: interwave.c,
#include <machine/pio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
@@ -90,6 +89,25 @@ struct audio_device iw_device = {
"guspnp"
};
+/* The HW supports more formats but only SLINEAR_NE/16/2ch is enough. */
+static const struct audio_format iw_formats[] = {
+ {
+ .mode = AUMODE_PLAY | AUMODE_RECORD,
+ .encoding = AUDIO_ENCODING_SLINEAR_NE,
+ .validbits = 16,
+ .precision = 16,
+ .channels = 2,
+ .channel_mask = AUFMT_STEREO,
+ .frequency_type = 16,
+ .frequency = {
+ 5510, 6620, 8000, 9600, 11025,
+ 16000, 18900, 22050, 27420, 32000,
+ 33075, 37800, 38400, 44100, 44800, 48000,
+ },
+ },
+};
+#define IW_NFORMATS __arraycount(iw_formats)
+
#ifdef AUDIO_DEBUG
int iw_debug;
#define DPRINTF(p) if (iw_debug) printf p
@@ -582,65 +600,14 @@ iw_set_speed(struct iw_softc *sc, u_long
return freq;
}
-/* Encoding. */
int
-iw_query_encoding(void *addr, audio_encoding_t *fp)
+iw_query_format(void *addr, audio_format_query_t *afp)
{
- /*
- * LINEAR, ALAW, ULAW, ADPCM in HW, we'll use linear unsigned
- * hardware mode for all 8-bit modes due to buggy (?) codec.
- */
- /*
- * except in wavetable synth. there we have only mu-law and 8 and 16
- * bit linear data
- */
-
- switch (fp->index) {
- case 0:
- strcpy(fp->name, AudioEulinear);
- fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
- 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, AudioEadpcm);
- fp->encoding = AUDIO_ENCODING_ADPCM;
- fp->precision = 8; /* really 4 bit */
- fp->flags = 0;
- 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, AudioEslinear_be);
- fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
- fp->precision = 16;
- fp->flags = 0;
- break;
- default:
- return EINVAL;
- /* NOTREACHED */
- }
- return 0;
+ return audio_query_format(iw_formats, IW_NFORMATS, afp);
}
-u_long
+static u_long
iw_set_format(struct iw_softc *sc, u_long precision, int in)
{
u_char data;
@@ -704,92 +671,40 @@ iw_set_format(struct iw_softc *sc, u_lon
}
int
-iw_set_params(void *addr, int setmode, int usemode, audio_params_t *p,
- audio_params_t *q, stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+iw_audio_set_format(void *addr, int setmode,
+ const audio_params_t *p, const audio_params_t *q,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
- audio_params_t phw, rhw;
struct iw_softc *sc;
- stream_filter_factory_t *swcode;
- DPRINTF(("iw_setparams: code %u, prec %u, rate %u, chan %u\n",
+ DPRINTF(("%s: code %u, prec %u, rate %u, chan %u\n", __func__,
p->encoding, p->precision, p->sample_rate, p->channels));
sc = addr;
- swcode = NULL;
- phw = *p;
- rhw = *q;
- switch (p->encoding) {
- case AUDIO_ENCODING_ULAW:
- if (p->precision != 8)
- return EINVAL;
- phw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- rhw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- swcode = setmode & AUMODE_PLAY ? mulaw_to_linear8 : linear8_to_mulaw;
- break;
- case AUDIO_ENCODING_ALAW:
- if (p->precision != 8)
- return EINVAL;
- phw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- rhw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- swcode = setmode & AUMODE_PLAY ? alaw_to_linear8 : linear8_to_alaw;
- break;
- case AUDIO_ENCODING_ADPCM:
- if (p->precision != 8)
- return EINVAL;
- else
- break;
-
- case AUDIO_ENCODING_SLINEAR_LE:
- case AUDIO_ENCODING_SLINEAR_BE:
- if (p->precision != 8 && p->precision != 16)
- return EINVAL;
- else
- break;
-
- default:
- return EINVAL;
-
- }
if (setmode & AUMODE_PLAY) {
sc->play_channels = p->channels;
sc->play_encoding = p->encoding;
sc->play_precision = p->precision;
iw_set_format(sc, p->precision, 0);
- q->sample_rate = p->sample_rate = sc->sc_orate =
- iw_set_speed(sc, p->sample_rate, 0);
- if (swcode != NULL) {
- phw.sample_rate = p->sample_rate;
- pfil->append(pfil, swcode, &phw);
- }
+ sc->sc_orate = iw_set_speed(sc, p->sample_rate, 0);
} else {
-#if 0
- q->channels = sc->rec_channels = p->channels;
- q->encoding = sc->rec_encoding = p->encoding;
- q->precision = sc->rec_precision = p->precision;
-#endif
sc->rec_channels = q->channels;
sc->rec_encoding = q->encoding;
sc->rec_precision = q->precision;
-
+ /* XXX Is this 'p' a typo of 'q' ? */
iw_set_format(sc, p->precision, 1);
- q->sample_rate = sc->sc_irate =
- iw_set_speed(sc, q->sample_rate, 1);
- if (swcode != NULL) {
- rhw.sample_rate = q->sample_rate;
- rfil->append(rfil, swcode, &rhw);
- }
+ sc->sc_irate = iw_set_speed(sc, q->sample_rate, 1);
}
return 0;
}
-
int
iw_round_blocksize(void *addr, int blk, int mode,
const audio_params_t *param)
{
/* Round to a multiple of the biggest sample size. */
- return blk &= -4;
+ return blk & -4;
}
void
Index: src/sys/dev/ic/interwavevar.h
diff -u src/sys/dev/ic/interwavevar.h:1.18 src/sys/dev/ic/interwavevar.h:1.18.42.1
--- src/sys/dev/ic/interwavevar.h:1.18 Sat Oct 27 17:18:21 2012
+++ src/sys/dev/ic/interwavevar.h Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: interwavevar.h,v 1.18 2012/10/27 17:18:21 chs Exp $ */
+/* $NetBSD: interwavevar.h,v 1.18.42.1 2019/04/21 06:00:00 isaki Exp $ */
/*
* Copyright (c) 1997, 1999, 2008 The NetBSD Foundation, Inc.
@@ -198,11 +198,11 @@ void iwattach(struct iw_softc *);
int iwopen(struct iw_softc *, int); /* open hardware */
void iwclose(void *); /* close hardware */
- /* Encoding. */
- /* XXX should we have separate in/out? */
-int iw_query_encoding(void *, struct audio_encoding *);
-int iw_set_params(void *, int, int, audio_params_t *, audio_params_t *,
- stream_filter_list_t *, stream_filter_list_t *);
+ /* Format. */
+int iw_query_format(void *, audio_format_query_t *);
+int iw_audio_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 iw_round_blocksize(void *, int, int, const audio_params_t *);
Index: src/sys/dev/isa/gus.c
diff -u src/sys/dev/isa/gus.c:1.115 src/sys/dev/isa/gus.c:1.115.2.1
--- src/sys/dev/isa/gus.c:1.115 Sat Mar 16 12:09:58 2019
+++ src/sys/dev/isa/gus.c Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gus.c,v 1.115 2019/03/16 12:09:58 isaki Exp $ */
+/* $NetBSD: gus.c,v 1.115.2.1 2019/04/21 06:00:00 isaki Exp $ */
/*-
* Copyright (c) 1996, 1999, 2008 The NetBSD Foundation, Inc.
@@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.115 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.115.2.1 2019/04/21 06:00:00 isaki Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -108,8 +108,6 @@ __KERNEL_RCSID(0, "$NetBSD: gus.c,v 1.11
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ics2101reg.h>
#include <dev/ic/cs4231reg.h>
@@ -361,10 +359,12 @@ int gus_set_in_gain(void *, u_int, u_cha
int gus_get_in_gain(void *);
int gus_set_out_gain(void *, u_int, u_char);
int gus_get_out_gain(void *);
-int gus_set_params(void *, int, int, audio_params_t *,
- audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
-int gusmax_set_params(void *, int, int, audio_params_t *,
- audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+int gus_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
+int gusmax_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
int gus_round_blocksize(void *, int, int, const audio_params_t *);
int gus_commit_settings(void *);
int gus_dma_output(void *, void *, int, void (*)(void *), void *);
@@ -420,7 +420,7 @@ STATIC int gusmax_mixer_set_port(void *,
STATIC int gusmax_mixer_get_port(void *, mixer_ctrl_t *);
STATIC int gus_mixer_query_devinfo(void *, mixer_devinfo_t *);
STATIC int gusmax_mixer_query_devinfo(void *, mixer_devinfo_t *);
-STATIC int gus_query_encoding(void *, struct audio_encoding *);
+STATIC int gus_query_format(void *, audio_format_query_t *);
STATIC int gus_get_props(void *);
STATIC int gusmax_get_props(void *);
@@ -578,8 +578,8 @@ static const unsigned short gus_log_volu
const struct audio_hw_if gus_hw_if = {
.open = gusopen,
.close = gusclose,
- .query_encoding = gus_query_encoding,
- .set_params = gus_set_params,
+ .query_format = gus_query_format,
+ .set_format = gus_set_format,
.round_blocksize = gus_round_blocksize,
.commit_settings = gus_commit_settings,
.start_output = gus_dma_output,
@@ -602,8 +602,8 @@ const struct audio_hw_if gus_hw_if = {
static const struct audio_hw_if gusmax_hw_if = {
.open = gusmaxopen,
.close = gusmax_close,
- .query_encoding = gus_query_encoding,
- .set_params = gusmax_set_params,
+ .query_format = gus_query_format,
+ .set_format = gusmax_set_format,
.round_blocksize = gusmax_round_blocksize,
.commit_settings = gusmax_commit_settings,
.start_output = gusmax_dma_output,
@@ -633,6 +633,21 @@ struct audio_device gus_device = {
"gus",
};
+/* The HW supports more formats but only SLINEAR_LE/16/2ch is enough. */
+STATIC const struct audio_format gus_formats[] = {
+ {
+ .mode = AUMODE_PLAY | AUMODE_RECORD,
+ .encoding = AUDIO_ENCODING_SLINEAR_LE,
+ .validbits = 16,
+ .precision = 16,
+ .channels = 2,
+ .channel_mask = AUFMT_STEREO,
+ .frequency_type = 1,
+ .frequency = { 44100 },
+ }
+};
+#define GUS_NFORMATS __arraycount(gus_formats)
+
#define FLIP_REV 5 /* This rev has flipped mixer chans */
@@ -2259,9 +2274,9 @@ gus_set_volume(struct gus_softc *sc, int
*/
int
-gusmax_set_params(void *addr, int setmode, int usemode, audio_params_t *p,
- audio_params_t *r, stream_filter_list_t *pfil,
- stream_filter_list_t *rfil)
+gusmax_set_format(void *addr, int setmode,
+ const audio_params_t *p, const audio_params_t *r,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
struct ad1848_isa_softc *ac;
struct gus_softc *sc;
@@ -2269,56 +2284,32 @@ gusmax_set_params(void *addr, int setmod
ac = addr;
sc = ac->sc_ad1848.parent;
- error = ad1848_set_params(ac, setmode, usemode, p, r, pfil, rfil);
+ error = ad1848_set_format(ac, setmode, p, r, pfil, rfil);
if (error)
return error;
- /*
- * ad1848_set_params() sets a filter for
- * SLINEAR_LE 8, SLINEAR_BE 16, ULINEAR_LE 16, ULINEAR_BE 16.
- * gus_set_params() sets a filter for
- * ULAW, ALAW, ULINEAR_BE (16), SLINEAR_BE (16)
- */
- error = gus_set_params(sc, setmode, usemode, p, r, pfil, rfil);
+
+ error = gus_set_format(sc, setmode, p, r, pfil, rfil);
return error;
}
int
-gus_set_params(void *addr,int setmode, int usemode, audio_params_t *p,
- audio_params_t *r, stream_filter_list_t *pfil,
- stream_filter_list_t *rfil)
+gus_set_format(void *addr, int setmode,
+ const audio_params_t *p, const audio_params_t *r,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
- audio_params_t hw;
struct gus_softc *sc;
sc = addr;
- switch (p->encoding) {
- case AUDIO_ENCODING_ULAW:
- case AUDIO_ENCODING_ALAW:
- case AUDIO_ENCODING_SLINEAR_LE:
- case AUDIO_ENCODING_ULINEAR_LE:
- case AUDIO_ENCODING_SLINEAR_BE:
- case AUDIO_ENCODING_ULINEAR_BE:
- break;
- default:
- return EINVAL;
- }
mutex_spin_enter(&sc->sc_codec.sc_ad1848.sc_intr_lock);
- if (p->precision == 8) {
- sc->sc_voc[GUS_VOICE_LEFT].voccntl &= ~GUSMASK_DATA_SIZE16;
- sc->sc_voc[GUS_VOICE_RIGHT].voccntl &= ~GUSMASK_DATA_SIZE16;
- } else {
- sc->sc_voc[GUS_VOICE_LEFT].voccntl |= GUSMASK_DATA_SIZE16;
- sc->sc_voc[GUS_VOICE_RIGHT].voccntl |= GUSMASK_DATA_SIZE16;
- }
+ sc->sc_voc[GUS_VOICE_LEFT].voccntl |= GUSMASK_DATA_SIZE16;
+ sc->sc_voc[GUS_VOICE_RIGHT].voccntl |= GUSMASK_DATA_SIZE16;
sc->sc_encoding = p->encoding;
sc->sc_precision = p->precision;
sc->sc_channels = p->channels;
- if (p->sample_rate > gus_max_frequency[sc->sc_voices - GUS_MIN_VOICES])
- p->sample_rate = gus_max_frequency[sc->sc_voices - GUS_MIN_VOICES];
if (setmode & AUMODE_RECORD)
sc->sc_irate = p->sample_rate;
if (setmode & AUMODE_PLAY)
@@ -2326,36 +2317,6 @@ gus_set_params(void *addr,int setmode, i
mutex_spin_exit(&sc->sc_codec.sc_ad1848.sc_intr_lock);
- hw = *p;
- /* clear req_size before setting a filter to avoid confliction
- * in gusmax_set_params() */
- switch (p->encoding) {
- case AUDIO_ENCODING_ULAW:
- hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- pfil->req_size = rfil->req_size = 0;
- pfil->append(pfil, mulaw_to_linear8, &hw);
- rfil->append(rfil, linear8_to_mulaw, &hw);
- break;
- case AUDIO_ENCODING_ALAW:
- hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- pfil->req_size = rfil->req_size = 0;
- pfil->append(pfil, alaw_to_linear8, &hw);
- rfil->append(rfil, linear8_to_alaw, &hw);
- break;
- case AUDIO_ENCODING_ULINEAR_BE:
- hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
- pfil->req_size = rfil->req_size = 0;
- pfil->append(pfil, swap_bytes, &hw);
- rfil->append(rfil, swap_bytes, &hw);
- break;
- case AUDIO_ENCODING_SLINEAR_BE:
- hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
- pfil->req_size = rfil->req_size = 0;
- pfil->append(pfil, swap_bytes, &hw);
- rfil->append(rfil, swap_bytes, &hw);
- break;
- }
-
return 0;
}
@@ -4020,64 +3981,10 @@ mute:
}
STATIC int
-gus_query_encoding(void *addr, struct audio_encoding *fp)
+gus_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;
- break;
- case 1:
- strcpy(fp->name, AudioEslinear);
- fp->encoding = AUDIO_ENCODING_SLINEAR;
- fp->precision = 8;
- fp->flags = 0;
- break;
- case 2:
- strcpy(fp->name, AudioEslinear_le);
- fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
- fp->precision = 16;
- fp->flags = 0;
- break;
- case 3:
- strcpy(fp->name, AudioEulinear);
- fp->encoding = AUDIO_ENCODING_ULINEAR;
- fp->precision = 8;
- fp->flags = 0;
- break;
- case 4:
- strcpy(fp->name, AudioEulinear_le);
- fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
- fp->precision = 16;
- fp->flags = 0;
- break;
- case 5:
- strcpy(fp->name, AudioEslinear_be);
- fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
- fp->precision = 16;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- case 6:
- strcpy(fp->name, AudioEulinear_be);
- fp->encoding = AUDIO_ENCODING_ULINEAR_BE;
- fp->precision = 16;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- case 7:
- strcpy(fp->name, AudioEalaw);
- fp->encoding = AUDIO_ENCODING_ALAW;
- fp->precision = 8;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
-
- default:
- return EINVAL;
- /*NOTREACHED*/
- }
- return 0;
+ return audio_query_format(gus_formats, GUS_NFORMATS, afp);
}
/*
Index: src/sys/dev/isa/wss.c
diff -u src/sys/dev/isa/wss.c:1.72 src/sys/dev/isa/wss.c:1.72.2.1
--- src/sys/dev/isa/wss.c:1.72 Sat Mar 16 12:09:58 2019
+++ src/sys/dev/isa/wss.c Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: wss.c,v 1.72 2019/03/16 12:09:58 isaki Exp $ */
+/* $NetBSD: wss.c,v 1.72.2.1 2019/04/21 06:00:00 isaki Exp $ */
/*
* Copyright (c) 1994 John Brezak
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wss.c,v 1.72 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wss.c,v 1.72.2.1 2019/04/21 06:00:00 isaki Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -87,8 +87,8 @@ int wss_query_devinfo(void *, mixer_devi
const struct audio_hw_if wss_hw_if = {
.open = ad1848_isa_open,
.close = ad1848_isa_close,
- .query_encoding = ad1848_query_encoding,
- .set_params = ad1848_set_params,
+ .query_format = ad1848_query_format,
+ .set_format = ad1848_set_format,
.round_blocksize = ad1848_round_blocksize,
.commit_settings = ad1848_commit_settings,
.halt_output = ad1848_isa_halt_output,
Index: src/sys/dev/isa/ym.c
diff -u src/sys/dev/isa/ym.c:1.45 src/sys/dev/isa/ym.c:1.45.2.1
--- src/sys/dev/isa/ym.c:1.45 Sat Mar 16 12:09:58 2019
+++ src/sys/dev/isa/ym.c Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ym.c,v 1.45 2019/03/16 12:09:58 isaki Exp $ */
+/* $NetBSD: ym.c,v 1.45.2.1 2019/04/21 06:00:00 isaki Exp $ */
/*-
* Copyright (c) 1999-2002, 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ym.c,v 1.45 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ym.c,v 1.45.2.1 2019/04/21 06:00:00 isaki Exp $");
#include "mpu_ym.h"
#include "opt_ym.h"
@@ -170,8 +170,8 @@ static bool ym_resume(device_t, const pm
const struct audio_hw_if ym_hw_if = {
.open = ad1848_isa_open,
.close = ad1848_isa_close,
- .query_encoding = ad1848_query_encoding,
- .set_params = ad1848_set_params,
+ .query_format = ad1848_query_format,
+ .set_format = ad1848_set_format,
.round_blocksize = ad1848_round_blocksize,
.commit_settings = ad1848_commit_settings,
.halt_output = ad1848_isa_halt_output,
Index: src/sys/dev/isapnp/gus_isapnp.c
diff -u src/sys/dev/isapnp/gus_isapnp.c:1.39 src/sys/dev/isapnp/gus_isapnp.c:1.39.2.1
--- src/sys/dev/isapnp/gus_isapnp.c:1.39 Sat Mar 16 12:09:58 2019
+++ src/sys/dev/isapnp/gus_isapnp.c Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gus_isapnp.c,v 1.39 2019/03/16 12:09:58 isaki Exp $ */
+/* $NetBSD: gus_isapnp.c,v 1.39.2.1 2019/04/21 06:00:00 isaki Exp $ */
/*
* Copyright (c) 1997, 1999, 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gus_isapnp.c,v 1.39 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gus_isapnp.c,v 1.39.2.1 2019/04/21 06:00:00 isaki Exp $");
#include "guspnp.h"
#if NGUSPNP > 0
@@ -66,8 +66,8 @@ static int gus_isapnp_open(void *, i
static const struct audio_hw_if guspnp_hw_if = {
.open = gus_isapnp_open,
.close = iwclose,
- .query_encoding = iw_query_encoding,
- .set_params = iw_set_params,
+ .query_format = iw_query_format,
+ .set_format = iw_audio_set_format,
.round_blocksize = iw_round_blocksize,
.commit_settings = iw_commit_settings,
.init_output = iw_init_output,
Index: src/sys/dev/sbus/cs4231_sbus.c
diff -u src/sys/dev/sbus/cs4231_sbus.c:1.51 src/sys/dev/sbus/cs4231_sbus.c:1.51.2.1
--- src/sys/dev/sbus/cs4231_sbus.c:1.51 Sat Mar 16 12:09:58 2019
+++ src/sys/dev/sbus/cs4231_sbus.c Sun Apr 21 06:00:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cs4231_sbus.c,v 1.51 2019/03/16 12:09:58 isaki Exp $ */
+/* $NetBSD: cs4231_sbus.c,v 1.51.2.1 2019/04/21 06:00:00 isaki Exp $ */
/*-
* Copyright (c) 1998, 1999, 2002, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cs4231_sbus.c,v 1.51 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cs4231_sbus.c,v 1.51.2.1 2019/04/21 06:00:00 isaki Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -99,8 +99,8 @@ static int cs4231_sbus_halt_input(void *
const struct audio_hw_if audiocs_sbus_hw_if = {
.open = cs4231_open,
.close = cs4231_close,
- .query_encoding = ad1848_query_encoding,
- .set_params = ad1848_set_params,
+ .query_format = ad1848_query_format,
+ .set_format = ad1848_set_format,
.commit_settings = ad1848_commit_settings,
.halt_output = cs4231_sbus_halt_output,
.halt_input = cs4231_sbus_halt_input,