Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/isaki-audio2]: src/sys Adapt am7930 families to audio2.



details:   https://anonhg.NetBSD.org/src/rev/c3c033dea597
branches:  isaki-audio2
changeset: 450696:c3c033dea597
user:      isaki <isaki%NetBSD.org@localhost>
date:      Mon Apr 22 13:29:34 2019 +0000

description:
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!

diffstat:

 sys/arch/sparc/dev/audioamd.c |   12 +--
 sys/arch/vax/vsa/vsaudio.c    |   11 +--
 sys/dev/ic/am7930.c           |  112 +++++++++------------------------------
 sys/dev/ic/am7930var.h        |   13 +--
 sys/dev/tc/bba.c              |  118 +++++++++++++----------------------------
 5 files changed, 75 insertions(+), 191 deletions(-)

diffs (truncated from 481 to 300 lines):

diff -r 12e80be97490 -r c3c033dea597 sys/arch/sparc/dev/audioamd.c
--- a/sys/arch/sparc/dev/audioamd.c     Mon Apr 22 12:30:26 2019 +0000
+++ b/sys/arch/sparc/dev/audioamd.c     Mon Apr 22 13:29:34 2019 +0000
@@ -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 @@
        audioamd_codec_iwrite16,
        audioamd_onopen,
        audioamd_onclose,
-       0,
-       0,
-       0,
 };
 
 /*
@@ -153,9 +150,8 @@
 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 */
diff -r 12e80be97490 -r c3c033dea597 sys/arch/vax/vsa/vsaudio.c
--- a/sys/arch/vax/vsa/vsaudio.c        Mon Apr 22 12:30:26 2019 +0000
+++ b/sys/arch/vax/vsa/vsaudio.c        Mon Apr 22 13:29:34 2019 +0000
@@ -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 @@
        vsaudio_codec_iwrite16,
        vsaudio_onopen,
        vsaudio_onclose,
-       0,
-       /*vsaudio_input_conv*/0,
-       /*vsaudio_output_conv*/0,
 };
 
 /*
@@ -186,9 +182,8 @@
 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,
diff -r 12e80be97490 -r c3c033dea597 sys/dev/ic/am7930.c
--- a/sys/dev/ic/am7930.c       Mon Apr 22 12:30:26 2019 +0000
+++ b/sys/dev/ic/am7930.c       Mon Apr 22 13:29:34 2019 +0000
@@ -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 @@
 
 #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 @@
 #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,99 +227,30 @@
        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;
+
+       return audio_query_format(&am7930_format, 1, afp);
+}
 
-       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);
-               }
+int
+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)
+{
 
+       if ((setmode & AUMODE_PLAY) != 0) {
+               pfil->codec = audio_internal_to_mulaw;
        }
-       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);
-               }
+       if ((setmode & AUMODE_RECORD) != 0) {
+               rfil->codec = audio_mulaw_to_internal;
        }
 
        return 0;
 }
 
 int
-am7930_query_encoding(void *addr, struct audio_encoding *fp)
-{
-       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*/
-       }
-       return 0;
-}
-
-int
-am7930_round_blocksize(void *addr, int blk,
-    int mode, const audio_params_t *param)
-{
-       return blk;
-}
-
-int
 am7930_commit_settings(void *addr)
 {
        struct am7930_softc *sc;
diff -r 12e80be97490 -r c3c033dea597 sys/dev/ic/am7930var.h
--- a/sys/dev/ic/am7930var.h    Mon Apr 22 12:30:26 2019 +0000
+++ b/sys/dev/ic/am7930var.h    Mon Apr 22 13:29:34 2019 +0000
@@ -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 @@
        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 @@
 
 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 *);
diff -r 12e80be97490 -r c3c033dea597 sys/dev/tc/bba.c
--- a/sys/dev/tc/bba.c  Mon Apr 22 12:30:26 2019 +0000
+++ b/sys/dev/tc/bba.c  Mon Apr 22 13:29:34 2019 +0000
@@ -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 @@
 
 #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 @@
 #include <dev/tc/ioasicreg.h>



Home | Main Index | Thread Index | Old Index