Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/isaki-audio2]: src/sys Adapt ad1848/cs4231 families to audio2.
details: https://anonhg.NetBSD.org/src/rev/01ecb3610e54
branches: isaki-audio2
changeset: 450630:01ecb3610e54
user: isaki <isaki%NetBSD.org@localhost>
date: Sun Apr 21 05:59:59 2019 +0000
description:
Adapt ad1848/cs4231 families to audio2.
diffstat:
sys/arch/amiga/dev/toccata.c | 8 +-
sys/arch/prep/isa/paud_isa.c | 9 +-
sys/dev/ebus/cs4231_ebus.c | 8 +-
sys/dev/ic/ad1848.c | 214 ++++++------------------------------------
sys/dev/ic/ad1848var.h | 10 +-
sys/dev/ic/interwave.c | 149 ++++++-----------------------
sys/dev/ic/interwavevar.h | 12 +-
sys/dev/isa/gus.c | 175 ++++++++--------------------------
sys/dev/isa/wss.c | 8 +-
sys/dev/isa/ym.c | 8 +-
sys/dev/isapnp/gus_isapnp.c | 8 +-
sys/dev/sbus/cs4231_sbus.c | 8 +-
12 files changed, 143 insertions(+), 474 deletions(-)
diffs (truncated from 1030 to 300 lines):
diff -r 91accde6c3cd -r 01ecb3610e54 sys/arch/amiga/dev/toccata.c
--- a/sys/arch/amiga/dev/toccata.c Sun Apr 21 05:22:57 2019 +0000
+++ b/sys/arch/amiga/dev/toccata.c Sun Apr 21 05:59:59 2019 +0000
@@ -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 @@
* 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? */
diff -r 91accde6c3cd -r 01ecb3610e54 sys/arch/prep/isa/paud_isa.c
--- a/sys/arch/prep/isa/paud_isa.c Sun Apr 21 05:22:57 2019 +0000
+++ b/sys/arch/prep/isa/paud_isa.c Sun Apr 21 05:59:59 2019 +0000
@@ -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 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 @@
.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,
diff -r 91accde6c3cd -r 01ecb3610e54 sys/dev/ebus/cs4231_ebus.c
--- a/sys/dev/ebus/cs4231_ebus.c Sun Apr 21 05:22:57 2019 +0000
+++ b/sys/dev/ebus/cs4231_ebus.c Sun Apr 21 05:59:59 2019 +0000
@@ -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 @@
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,
diff -r 91accde6c3cd -r 01ecb3610e54 sys/dev/ic/ad1848.c
--- a/sys/dev/ic/ad1848.c Sun Apr 21 05:22:57 2019 +0000
+++ b/sys/dev/ic/ad1848.c Sun Apr 21 05:59:59 2019 +0000
@@ -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 @@
#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 @@
#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 @@
}
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;
Home |
Main Index |
Thread Index |
Old Index