Module Name: src
Committed By: isaki
Date: Mon Apr 22 13:29:34 UTC 2019
Modified Files:
src/sys/arch/sparc/dev [isaki-audio2]: audioamd.c
src/sys/arch/vax/vsa [isaki-audio2]: vsaudio.c
src/sys/dev/ic [isaki-audio2]: am7930.c am7930var.h
src/sys/dev/tc [isaki-audio2]: bba.c
Log Message:
Adapt am7930 families to audio2.
- Remove {input/output}_conv stuff from am7930_glue.
Filter pipelines for user encoding are not necessary in audio2
so the driver only needs to handle its hardware encoding.
- audioamd/vsaudio use an ordinal linear-mulaw conversion filter
and bba requires special one. dev/audio/mulaw.c supports this
variant just for bba. It might not a good way for bba but it
keeps all other drivers simple.
- Tested on vsaudio(4) by naru@, bba(4) by tsutsui@ (a few months ago).
Thanks!
To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/arch/sparc/dev/audioamd.c
cvs rdiff -u -r1.4 -r1.4.2.1 src/sys/arch/vax/vsa/vsaudio.c
cvs rdiff -u -r1.57 -r1.57.8.1 src/sys/dev/ic/am7930.c
cvs rdiff -u -r1.13 -r1.13.54.1 src/sys/dev/ic/am7930var.h
cvs rdiff -u -r1.42 -r1.42.2.1 src/sys/dev/tc/bba.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/sparc/dev/audioamd.c
diff -u src/sys/arch/sparc/dev/audioamd.c:1.28 src/sys/arch/sparc/dev/audioamd.c:1.28.2.1
--- src/sys/arch/sparc/dev/audioamd.c:1.28 Sat Mar 16 12:09:57 2019
+++ src/sys/arch/sparc/dev/audioamd.c Mon Apr 22 13:29:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: audioamd.c,v 1.28 2019/03/16 12:09:57 isaki Exp $ */
+/* $NetBSD: audioamd.c,v 1.28.2.1 2019/04/22 13:29:34 isaki Exp $ */
/* NetBSD: am7930_sparc.c,v 1.44 1999/03/14 22:29:00 jonathan Exp */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audioamd.c,v 1.28 2019/03/16 12:09:57 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audioamd.c,v 1.28.2.1 2019/04/22 13:29:34 isaki Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -137,9 +137,6 @@ struct am7930_glue audioamd_glue = {
audioamd_codec_iwrite16,
audioamd_onopen,
audioamd_onclose,
- 0,
- 0,
- 0,
};
/*
@@ -153,9 +150,8 @@ void audioamd_get_locks(void *opaque, km
const struct audio_hw_if sa_hw_if = {
.open = am7930_open,
.close = am7930_close,
- .query_encoding = am7930_query_encoding,
- .set_params = am7930_set_params,
- .round_blocksize = am7930_round_blocksize,
+ .query_format = am7930_query_format,
+ .set_format = am7930_set_format,
.commit_settings = am7930_commit_settings,
.start_output = audioamd_start_output, /* md */
.start_input = audioamd_start_input, /* md */
Index: src/sys/arch/vax/vsa/vsaudio.c
diff -u src/sys/arch/vax/vsa/vsaudio.c:1.4 src/sys/arch/vax/vsa/vsaudio.c:1.4.2.1
--- src/sys/arch/vax/vsa/vsaudio.c:1.4 Mon Apr 8 14:48:33 2019
+++ src/sys/arch/vax/vsa/vsaudio.c Mon Apr 22 13:29:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: vsaudio.c,v 1.4 2019/04/08 14:48:33 isaki Exp $ */
+/* $NetBSD: vsaudio.c,v 1.4.2.1 2019/04/22 13:29:34 isaki Exp $ */
/* $OpenBSD: vsaudio.c,v 1.4 2013/05/15 21:21:11 ratchov Exp $ */
/*
@@ -78,7 +78,6 @@
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/ic/am7930reg.h>
#include <dev/ic/am7930var.h>
@@ -170,9 +169,6 @@ struct am7930_glue vsaudio_glue = {
vsaudio_codec_iwrite16,
vsaudio_onopen,
vsaudio_onclose,
- 0,
- /*vsaudio_input_conv*/0,
- /*vsaudio_output_conv*/0,
};
/*
@@ -186,9 +182,8 @@ void vsaudio_get_locks(void *opaque, kmu
struct audio_hw_if vsaudio_hw_if = {
.open = am7930_open,
.close = am7930_close,
- .query_encoding = am7930_query_encoding,
- .set_params = am7930_set_params,
- .round_blocksize = am7930_round_blocksize,
+ .query_format = am7930_query_format,
+ .set_format = am7930_set_format,
.commit_settings = am7930_commit_settings,
.start_output = vsaudio_start_output,
.start_input = vsaudio_start_input,
Index: src/sys/dev/ic/am7930.c
diff -u src/sys/dev/ic/am7930.c:1.57 src/sys/dev/ic/am7930.c:1.57.8.1
--- src/sys/dev/ic/am7930.c:1.57 Tue Aug 29 06:38:49 2017
+++ src/sys/dev/ic/am7930.c Mon Apr 22 13:29:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am7930.c,v 1.57 2017/08/29 06:38:49 isaki Exp $ */
+/* $NetBSD: am7930.c,v 1.57.8.1 2019/04/22 13:29:34 isaki Exp $ */
/*
* Copyright (c) 1995 Rolf Grossmann
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am7930.c,v 1.57 2017/08/29 06:38:49 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am7930.c,v 1.57.8.1 2019/04/22 13:29:34 isaki Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: am7930.c,v 1
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
+#include <dev/audio/mulaw.h>
#include <dev/ic/am7930reg.h>
#include <dev/ic/am7930var.h>
@@ -137,7 +137,16 @@ static const uint16_t ger_coeff[] = {
#define NGER (sizeof(ger_coeff) / sizeof(ger_coeff[0]))
};
-extern stream_filter_factory_t null_filter;
+static const struct audio_format am7930_format = {
+ .mode = AUMODE_PLAY | AUMODE_RECORD,
+ .encoding = AUDIO_ENCODING_ULAW,
+ .validbits = 8,
+ .precision = 8,
+ .channels = 1,
+ .channel_mask = AUFMT_MONAURAL,
+ .frequency_type = 1,
+ .frequency = { 8000 },
+};
/*
* Reset chip and set boot-time softc defaults.
@@ -218,96 +227,27 @@ am7930_close(void *addr)
DPRINTF(("sa_close: closed.\n"));
}
-/*
- * XXX should be extended to handle a few of the more common formats.
- */
int
-am7930_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)
+am7930_query_format(void *addr, audio_format_query_t *afp)
{
- audio_params_t hw;
- struct am7930_softc *sc;
-
- sc = addr;
- if ((usemode & AUMODE_PLAY) == AUMODE_PLAY) {
- if (p->sample_rate < 7500 || p->sample_rate > 8500 ||
- (p->encoding != AUDIO_ENCODING_ULAW &&
- p->encoding != AUDIO_ENCODING_SLINEAR) ||
- p->precision != 8 ||
- p->channels != 1)
- return EINVAL;
- p->sample_rate = 8000;
- if (sc->sc_glue->output_conv != NULL) {
- hw = *p;
- hw.encoding = AUDIO_ENCODING_NONE;
- hw.precision = 8;
- pfil->append(pfil, null_filter, &hw);
- hw.precision *= sc->sc_glue->factor;
- pfil->append(pfil, sc->sc_glue->output_conv, &hw);
- }
- if (p->encoding == AUDIO_ENCODING_SLINEAR) {
- hw = *p;
- hw.precision = 8;
- hw.encoding = AUDIO_ENCODING_ULAW;
- pfil->append(pfil, linear8_to_mulaw, &hw);
- }
- }
- if ((usemode & AUMODE_RECORD) == AUMODE_RECORD) {
- if (r->sample_rate < 7500 || r->sample_rate > 8500 ||
- (r->encoding != AUDIO_ENCODING_ULAW &&
- r->encoding != AUDIO_ENCODING_SLINEAR) ||
- r->precision != 8 ||
- r->channels != 1)
- return EINVAL;
- r->sample_rate = 8000;
- if (sc->sc_glue->input_conv != NULL) {
- hw = *r;
- hw.encoding = AUDIO_ENCODING_NONE;
- hw.precision = 8;
- rfil->append(rfil, null_filter, &hw);
- hw.precision *= sc->sc_glue->factor;
- rfil->append(rfil, sc->sc_glue->input_conv, &hw);
- }
- if (r->encoding == AUDIO_ENCODING_SLINEAR) {
- hw = *r;
- hw.precision = 8;
- hw.encoding = AUDIO_ENCODING_ULAW;
- rfil->append(rfil, mulaw_to_linear8, &hw);
- }
- }
-
- return 0;
+ return audio_query_format(&am7930_format, 1, afp);
}
int
-am7930_query_encoding(void *addr, struct audio_encoding *fp)
+am7930_set_format(void *addr, int setmode,
+ const audio_params_t *play, const audio_params_t *rec,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
- 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, AudioEslinear);
- fp->encoding = AUDIO_ENCODING_SLINEAR;
- fp->precision = 8;
- fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
- break;
- default:
- return EINVAL;
- /*NOTREACHED*/
+
+ if ((setmode & AUMODE_PLAY) != 0) {
+ pfil->codec = audio_internal_to_mulaw;
+ }
+ if ((setmode & AUMODE_RECORD) != 0) {
+ rfil->codec = audio_mulaw_to_internal;
}
- return 0;
-}
-int
-am7930_round_blocksize(void *addr, int blk,
- int mode, const audio_params_t *param)
-{
- return blk;
+ return 0;
}
int
Index: src/sys/dev/ic/am7930var.h
diff -u src/sys/dev/ic/am7930var.h:1.13 src/sys/dev/ic/am7930var.h:1.13.54.1
--- src/sys/dev/ic/am7930var.h:1.13 Wed Nov 23 23:07:32 2011
+++ src/sys/dev/ic/am7930var.h Mon Apr 22 13:29:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am7930var.h,v 1.13 2011/11/23 23:07:32 jmcneill Exp $ */
+/* $NetBSD: am7930var.h,v 1.13.54.1 2019/04/22 13:29:34 isaki Exp $ */
struct am7930_softc;
@@ -9,9 +9,6 @@ struct am7930_glue {
void (*codec_iwrite16)(struct am7930_softc *sc, int, uint16_t);
void (*onopen)(struct am7930_softc *sc);
void (*onclose)(struct am7930_softc *sc);
- int factor;
- stream_filter_factory_t *input_conv;
- stream_filter_factory_t *output_conv;
};
struct am7930_softc {
@@ -70,11 +67,11 @@ struct audio_params;
int am7930_open(void *, int);
void am7930_close(void *);
-int am7930_query_encoding(void *, struct audio_encoding *);
-int am7930_set_params(void *, int, int, audio_params_t *,
- audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+int am7930_query_format(void *, audio_format_query_t *);
+int am7930_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
int am7930_commit_settings(void *);
-int am7930_round_blocksize(void *, int, int, const audio_params_t *);
int am7930_halt_output(void *);
int am7930_halt_input(void *);
int am7930_getdev(void *, struct audio_device *);
Index: src/sys/dev/tc/bba.c
diff -u src/sys/dev/tc/bba.c:1.42 src/sys/dev/tc/bba.c:1.42.2.1
--- src/sys/dev/tc/bba.c:1.42 Sat Mar 16 12:09:58 2019
+++ src/sys/dev/tc/bba.c Mon Apr 22 13:29:34 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: bba.c,v 1.42 2019/03/16 12:09:58 isaki Exp $ */
+/* $NetBSD: bba.c,v 1.42.2.1 2019/04/22 13:29:34 isaki Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
/* maxine/alpha baseboard audio (bba) */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bba.c,v 1.42 2019/03/16 12:09:58 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bba.c,v 1.42.2.1 2019/04/22 13:29:34 isaki Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -43,7 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: bba.c,v 1.42
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/ic/am7930reg.h>
#include <dev/ic/am7930var.h>
@@ -52,6 +51,12 @@ __KERNEL_RCSID(0, "$NetBSD: bba.c,v 1.42
#include <dev/tc/ioasicreg.h>
#include <dev/tc/ioasicvar.h>
+/* include mulaw.c (not .h file) here to expand mulaw32 */
+void audio_mulaw32_to_internal(audio_filter_arg_t *);
+void audio_internal_to_mulaw32(audio_filter_arg_t *);
+#define MULAW32
+#include <dev/audio/mulaw.c>
+
#ifdef AUDIO_DEBUG
#define DPRINTF(x) if (am7930debug) printf x
#else
@@ -109,13 +114,6 @@ static void bba_codec_iwrite16(struct am
static void bba_onopen(struct am7930_softc *);
static void bba_onclose(struct am7930_softc *);
-static stream_filter_factory_t bba_output_conv;
-static stream_filter_factory_t bba_input_conv;
-static int bba_output_conv_fetch_to(struct audio_softc *, stream_fetcher_t *,
- audio_stream_t *, int);
-static int bba_input_conv_fetch_to(struct audio_softc *, stream_fetcher_t *,
- audio_stream_t *, int);
-
struct am7930_glue bba_glue = {
bba_codec_iread,
bba_codec_iwrite,
@@ -123,15 +121,16 @@ struct am7930_glue bba_glue = {
bba_codec_iwrite16,
bba_onopen,
bba_onclose,
- 4,
- bba_input_conv,
- bba_output_conv,
};
/*
* Define our interface to the higher level audio driver.
*/
+static int bba_query_format(void *, audio_format_query_t *);
+static int bba_set_format(void *, int,
+ const audio_params_t *, const audio_params_t *,
+ audio_filter_reg_t *, audio_filter_reg_t *);
static int bba_round_blocksize(void *, int, int, const audio_params_t *);
static int bba_halt_output(void *);
static int bba_halt_input(void *);
@@ -140,7 +139,6 @@ static void *bba_allocm(void *, int, siz
static void bba_freem(void *, void *, size_t);
static size_t bba_round_buffersize(void *, int, size_t);
static int bba_get_props(void *);
-static paddr_t bba_mappage(void *, void *, off_t, int);
static int bba_trigger_output(void *, void *, void *, int,
void (*)(void *), void *,
const audio_params_t *);
@@ -153,8 +151,8 @@ static void bba_get_locks(void *opaque,
static const struct audio_hw_if sa_hw_if = {
.open = am7930_open,
.close = am7930_close,
- .query_encoding = am7930_query_encoding,
- .set_params = am7930_set_params,
+ .query_format = bba_query_format,
+ .set_format = bba_set_format,
.round_blocksize = bba_round_blocksize, /* md */
.commit_settings = am7930_commit_settings,
.halt_output = bba_halt_output, /* md */
@@ -166,7 +164,6 @@ static const struct audio_hw_if sa_hw_if
.allocm = bba_allocm, /* md */
.freem = bba_freem, /* md */
.round_buffersize = bba_round_buffersize, /* md */
- .mappage = bba_mappage,
.get_props = bba_get_props,
.trigger_output = bba_trigger_output, /* md */
.trigger_input = bba_trigger_input, /* md */
@@ -179,6 +176,17 @@ static struct audio_device bba_device =
"bba"
};
+static const struct audio_format bba_format = {
+ .mode = AUMODE_PLAY | AUMODE_RECORD,
+ .encoding = AUDIO_ENCODING_ULAW, /* XXX */
+ .validbits = 32,
+ .precision = 32,
+ .channels = 1,
+ .channel_mask = AUFMT_MONAURAL,
+ .frequency_type = 1,
+ .frequency = { 8000 },
+};
+
static int bba_intr(void *);
static void bba_reset(struct bba_softc *, int);
static void bba_codec_dwrite(struct am7930_softc *, int, uint8_t);
@@ -617,78 +625,26 @@ bba_get_props(void *addr)
return AUDIO_PROP_MMAP | am7930_get_props(addr);
}
-static paddr_t
-bba_mappage(void *addr, void *mem, off_t offset, int prot)
-{
- struct bba_softc *sc;
- struct bba_mem **mp;
- bus_dma_segment_t seg;
- void *kva;
-
- sc = addr;
- kva = (void *)mem;
- for (mp = &sc->sc_mem_head; *mp && (*mp)->kva != kva;
- mp = &(*mp)->next)
- continue;
- if (*mp == NULL || offset < 0) {
- return -1;
- }
-
- seg.ds_addr = (*mp)->addr;
- seg.ds_len = (*mp)->size;
-
- return bus_dmamem_mmap(sc->sc_dmat, &seg, 1, offset,
- prot, BUS_DMA_WAITOK);
-}
-
-static stream_filter_t *
-bba_input_conv(struct audio_softc *sc, const audio_params_t *from,
- const audio_params_t *to)
-{
- return auconv_nocontext_filter_factory(bba_input_conv_fetch_to);
-}
-
static int
-bba_input_conv_fetch_to(struct audio_softc *sc, stream_fetcher_t *self,
- audio_stream_t *dst, int max_used)
+bba_query_format(void *addr, audio_format_query_t *afp)
{
- 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 *
-bba_output_conv(struct audio_softc *sc, const audio_params_t *from,
- const audio_params_t *to)
-{
- return auconv_nocontext_filter_factory(bba_output_conv_fetch_to);
+ return audio_query_format(&bba_format, 1, afp);
}
static int
-bba_output_conv_fetch_to(struct audio_softc *sc, stream_fetcher_t *self,
- audio_stream_t *dst, int max_used)
+bba_set_format(void *addr, int setmode,
+ const audio_params_t *play, const audio_params_t *rec,
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
- 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);
+ if ((setmode & AUMODE_PLAY) != 0) {
+ pfil->codec = audio_internal_to_mulaw32;
+ }
+ if ((setmode & AUMODE_RECORD) != 0) {
+ rfil->codec = audio_mulaw32_to_internal;
+ }
+
return 0;
}