Source-Changes-HG archive

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

[src/trunk]: src/sys merge kent-audio1 branch, which introduces audio filter ...



details:   https://anonhg.NetBSD.org/src/rev/9ab014c597e1
branches:  trunk
changeset: 572710:9ab014c597e1
user:      kent <kent%NetBSD.org@localhost>
date:      Mon Jan 10 22:01:36 2005 +0000

description:
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
  - remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels.  Conversion information
is conveyed by stream_filter_list_t.
  - change the type of sample_rate: u_long -> u_int
  - add `validbits,' which represents the valid data size in
precision bits.  It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
 - add two parameters to set_params()
        stream_filter_list_t *pfil, stream_filter_list *rfil
   A HW driver should set filter recipes for requested formats
 - constify audio_params parameters of trigger_output() and
trigger_input().  They represent audio formats for the hardware.
 - make open() and close() optional
 - add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
 to round_blocksize()

* sw_code is replaced with stream_filter_t.
  stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
  converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
 - audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
 - audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
 - audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
 - ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes

diffstat:

 sys/arch/amiga/dev/aucc.c        |    24 +-
 sys/arch/amiga/dev/repulse.c     |    49 +-
 sys/arch/amiga/dev/toccata.c     |    10 +-
 sys/arch/arm/iomd/files.iomd     |     4 +-
 sys/arch/arm/iomd/vidcaudio.c    |   144 +-
 sys/arch/dreamcast/dev/g2/aica.c |   141 +--
 sys/arch/hp700/gsc/harmony.c     |    49 +-
 sys/arch/hpcmips/vr/vraiu.c      |    17 +-
 sys/arch/macppc/dev/awacs.c      |   194 +---
 sys/arch/macppc/dev/snapper.c    |   158 +--
 sys/arch/sgimips/hpc/haltwo.c    |   109 +-
 sys/arch/x68k/dev/vs.c           |    85 +-
 sys/arch/x68k/dev/vsvar.h        |     4 +-
 sys/conf/files                   |     4 +-
 sys/dev/auconv.c                 |   699 +++++++++------
 sys/dev/auconv.h                 |    64 +-
 sys/dev/audio.c                  |  1589 ++++++++++++++++++++-----------------
 sys/dev/audio_if.h               |   149 ++-
 sys/dev/audiovar.h               |   153 +-
 sys/dev/aurateconv.c             |   651 +++++++-------
 sys/dev/ebus/cs4231_ebus.c       |    11 +-
 sys/dev/ic/ac97.c                |    74 +-
 sys/dev/ic/ac97var.h             |    14 +-
 sys/dev/ic/ad1848.c              |    52 +-
 sys/dev/ic/ad1848var.h           |    11 +-
 sys/dev/ic/am7930.c              |    30 +-
 sys/dev/ic/am7930var.h           |    13 +-
 sys/dev/ic/interwave.c           |    49 +-
 sys/dev/ic/interwavevar.h        |    15 +-
 sys/dev/ic/msm6258.c             |   410 ++++++---
 sys/dev/ic/msm6258var.h          |    23 +-
 sys/dev/ic/tms320av110.c         |    25 +-
 sys/dev/isa/ad1848_isa.c         |    17 +-
 sys/dev/isa/ad1848var.h          |     8 +-
 sys/dev/isa/aria.c               |    48 +-
 sys/dev/isa/ess.c                |   134 +-
 sys/dev/isa/gus.c                |    73 +-
 sys/dev/isa/sb.c                 |     6 +-
 sys/dev/isa/sbdsp.c              |   113 +-
 sys/dev/isa/sbdspvar.h           |    11 +-
 sys/dev/mulaw.c                  |   481 +++++------
 sys/dev/mulaw.h                  |    52 +-
 sys/dev/pci/auacer.c             |    60 +-
 sys/dev/pci/auich.c              |    72 +-
 sys/dev/pci/autri.c              |   120 +-
 sys/dev/pci/auvia.c              |    83 +-
 sys/dev/pci/cmpci.c              |   205 +---
 sys/dev/pci/cs4280.c             |    89 +-
 sys/dev/pci/cs4281.c             |    75 +-
 sys/dev/pci/cs428x.c             |    18 +-
 sys/dev/pci/cs428x.h             |     6 +-
 sys/dev/pci/eap.c                |   111 +-
 sys/dev/pci/emuxki.c             |   147 +--
 sys/dev/pci/esa.c                |   121 +-
 sys/dev/pci/esm.c                |   122 +-
 sys/dev/pci/esmvar.h             |    14 +-
 sys/dev/pci/eso.c                |   140 +-
 sys/dev/pci/fms.c                |   164 +--
 sys/dev/pci/neo.c                |   123 +-
 sys/dev/pci/sv.c                 |   126 +-
 sys/dev/pci/yds.c                |    82 +-
 sys/dev/pcmcia/esl.c             |    44 +-
 sys/dev/sbus/cs4231_sbus.c       |    12 +-
 sys/dev/tc/bba.c                 |   107 +-
 sys/dev/tc/files.tc              |     4 +-
 sys/dev/usb/uaudio.c             |    52 +-
 66 files changed, 3941 insertions(+), 4123 deletions(-)

diffs (truncated from 14486 to 300 lines):

diff -r cb430a99183a -r 9ab014c597e1 sys/arch/amiga/dev/aucc.c
--- a/sys/arch/amiga/dev/aucc.c Mon Jan 10 21:43:08 2005 +0000
+++ b/sys/arch/amiga/dev/aucc.c Mon Jan 10 22:01:36 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aucc.c,v 1.35 2004/10/29 12:57:15 yamt Exp $ */
+/*     $NetBSD: aucc.c,v 1.36 2005/01/10 22:01:36 kent Exp $ */
 
 /*
  * Copyright (c) 1999 Bernardo Innocenti
@@ -53,7 +53,7 @@
 #if NAUCC > 0
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aucc.c,v 1.35 2004/10/29 12:57:15 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aucc.c,v 1.36 2005/01/10 22:01:36 kent Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -189,9 +189,9 @@
  */
 int    aucc_open(void *, int);
 void   aucc_close(void *);
-int    aucc_set_out_sr(void *, u_long);
+int    aucc_set_out_sr(void *, u_int);
 int    aucc_query_encoding(void *, struct audio_encoding *);
-int    aucc_round_blocksize(void *, int);
+int    aucc_round_blocksize(void *, int, int, const audio_params_t *);
 int    aucc_commit_settings(void *);
 int    aucc_start_output(void *, void *, int, void (*)(void *), void *);
 int    aucc_start_input(void *, void *, int, void (*)(void *), void *);
@@ -202,8 +202,8 @@
 int    aucc_get_port(void *, mixer_ctrl_t *);
 int    aucc_query_devinfo(void *, mixer_devinfo_t *);
 void   aucc_encode(int, int, int, int, u_char *, u_short **);
-int    aucc_set_params(void *, int, int, struct audio_params *,
-                       struct audio_params *);
+int    aucc_set_params(void *, int, int, audio_params_t *, audio_params_t *,
+                       stream_filter_list_t *, stream_filter_list_t *);
 int    aucc_get_props(void *);
 
 
@@ -383,7 +383,7 @@
 }
 
 int
-aucc_set_out_sr(void *addr, u_long sr)
+aucc_set_out_sr(void *addr, u_int sr)
 {
        struct aucc_softc *sc=addr;
        u_long per;
@@ -455,8 +455,9 @@
 }
 
 int
-aucc_set_params(void *addr, int setmode, int usemode, struct audio_params *p,
-                struct audio_params *r)
+aucc_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)
 {
        struct aucc_softc *sc = addr;
 
@@ -465,7 +466,7 @@
 
 #ifdef AUCCDEBUG
        printf("aucc_set_params(setmode 0x%x, usemode 0x%x, "
-               "enc %d, bits %d, chn %d, sr %ld)\n", setmode, usemode,
+               "enc %u, bits %u, chn %u, sr %u)\n", setmode, usemode,
                p->encoding, p->precision, p->channels, p->sample_rate);
 #endif
 
@@ -603,7 +604,8 @@
 }
 
 int
-aucc_round_blocksize(void *addr, int blk)
+aucc_round_blocksize(void *addr, int blk,
+                    int mode, const audio_params_t *param)
 {
        /* round up to even size */
        return blk > AUDIO_BUF_SIZE ? AUDIO_BUF_SIZE : blk;
diff -r cb430a99183a -r 9ab014c597e1 sys/arch/amiga/dev/repulse.c
--- a/sys/arch/amiga/dev/repulse.c      Mon Jan 10 21:43:08 2005 +0000
+++ b/sys/arch/amiga/dev/repulse.c      Mon Jan 10 22:01:36 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: repulse.c,v 1.11 2004/11/09 16:18:58 kent Exp $ */
+/*     $NetBSD: repulse.c,v 1.12 2005/01/10 22:01:36 kent Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: repulse.c,v 1.11 2004/11/09 16:18:58 kent Exp $");
+__KERNEL_RCSID(0, "$NetBSD: repulse.c,v 1.12 2005/01/10 22:01:36 kent Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -80,16 +80,15 @@
 
 /* audio attachment functions */
 
-int rep_open(void *, int);
 void rep_close(void *);
 int rep_getdev(void *, struct audio_device *);
 int rep_get_props(void *);
 int rep_halt_output(void *);
 int rep_halt_input(void *);
 int rep_query_encoding(void *, struct audio_encoding *);
-int rep_set_params(void *, int, int, struct audio_params *,
-    struct audio_params *);
-int rep_round_blocksize(void *, int);
+int rep_set_params(void *, int, int, audio_params_t *,
+    audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
+int rep_round_blocksize(void *, int, int, const audio_params_t *);
 int rep_set_port(void *, mixer_ctrl_t *);
 int rep_get_port(void *, mixer_ctrl_t *);
 int rep_query_devinfo(void *, mixer_devinfo_t *);
@@ -104,7 +103,7 @@
 /* audio attachment */
 
 const struct audio_hw_if rep_hw_if = {
-       rep_open,
+       /* open */ 0,
        rep_close,
        /* drain */ 0,
        rep_query_encoding,
@@ -317,7 +316,7 @@
        sc->sc_achost.attach = repac_attach;
        sc->sc_achost.flags = 0;
 
-       if (ac97_attach(&sc->sc_achost)) {
+       if (ac97_attach(&sc->sc_achost, self)) {
                printf("%s: error attaching codec\n", self->dv_xname);
                return;
        }
@@ -418,12 +417,6 @@
 
 /* audio(9) support stuff which is not ac97-constant */
 
-int
-rep_open(void *arg, int flags)
-{
-       return 0;
-}
-
 void
 rep_close(void *arg)
 {
@@ -550,7 +543,7 @@
 }
 
 int
-rep_round_blocksize(void *arg, int blk)
+rep_round_blocksize(void *arg, int blk, int mode, const audio_params_t *param)
 {
        int b1;
 
@@ -570,10 +563,12 @@
 
 int
 rep_set_params(void *addr, int setmode, int usemode,
-       struct audio_params *play, struct audio_params *rec)
+       audio_params_t *play, audio_params_t *rec,
+       stream_filter_list_t *pfil, stream_filter_list_t *rfil)
 {
+       audio_params_t hw;
        struct repulse_softc *sc = addr;
-       struct audio_params *p;
+       audio_params_t *p;
        int mode, reg;
        unsigned  flags;
        u_int16_t a;
@@ -605,8 +600,7 @@
                else
                        sc->sc_captscale = p->channels * p->precision / 8;
 
-               p->factor = 1;
-               p->sw_code = 0;
+               hw = *p;
 
                /* everything else is software, alas... */
                /* XXX TBD signed/unsigned, *law, etc */
@@ -629,8 +623,9 @@
                                        rep_write_16_stereo;
                                sc->sc_playflags = 0;
                                sc->sc_playscale = p->channels * 2;
-                               p->sw_code = mulaw_to_slinear16_be;
-                               p->factor = 2;
+                               hw.encoding = AUDIO_ENCODING_SLINEAR_BE;
+                               hw.precision = hw.validbits = 16;
+                               pfil->append(pfil, mulaw_to_linear16, &hw);
                        } else
                        if (p->encoding == AUDIO_ENCODING_ALAW) {
                                sc->sc_playfun = p->channels == 1 ?
@@ -638,8 +633,9 @@
                                        rep_write_16_stereo;
                                sc->sc_playflags = 0;
                                sc->sc_playscale = p->channels * 2;
-                               p->sw_code = alaw_to_slinear16_be;
-                               p->factor = 2;
+                               hw.encoding = AUDIO_ENCODING_SLINEAR_BE;
+                               hw.precision = hw.validbits = 16;
+                               pfil->append(pfil, alaw_to_linear16, &hw);
                        } else
                        if (p->precision == 8 && p->channels == 1)
                                sc->sc_playfun = rep_write_8_mono;
@@ -656,16 +652,15 @@
                                        rep_read_8_mono :
                                        rep_read_8_stereo;
                                sc->sc_captflags = 0;
-                               p->sw_code = slinear8_to_mulaw;
-                               p->factor = 1;
+                               hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
+                               rfil->append(rfil, linear8_to_mulaw, &hw);
                        } else
                        if (p->encoding == AUDIO_ENCODING_ALAW) {
                                sc->sc_captfun = p->channels == 1 ?
                                        rep_read_8_mono :
                                        rep_read_8_stereo;
                                sc->sc_captflags = 0;
-                               p->sw_code = slinear8_to_alaw;
-                               p->factor = 1;
+                               rfil->append(rfil, linear8_to_alaw, &hw);
                        } else
                        if (p->precision == 8 && p->channels == 1)
                                sc->sc_captfun = rep_read_8_mono;
diff -r cb430a99183a -r 9ab014c597e1 sys/arch/amiga/dev/toccata.c
--- a/sys/arch/amiga/dev/toccata.c      Mon Jan 10 21:43:08 2005 +0000
+++ b/sys/arch/amiga/dev/toccata.c      Mon Jan 10 22:01:36 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: toccata.c,v 1.8 2004/10/29 12:57:16 yamt Exp $ */
+/* $NetBSD: toccata.c,v 1.9 2005/01/10 22:01:36 kent Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: toccata.c,v 1.8 2004/10/29 12:57:16 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: toccata.c,v 1.9 2005/01/10 22:01:36 kent Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -165,7 +165,7 @@
 int toccata_readreg(struct ad1848_softc *, int);
 void toccata_writereg(struct ad1848_softc *, int, int);
 
-int toccata_round_blocksize(void *, int);
+int toccata_round_blocksize(void *, int, int, const audio_params_t *);
 size_t toccata_round_buffersize(void *, int, size_t);
 
 int toccata_open(void *, int);
@@ -407,7 +407,9 @@
 }
 
 int
-toccata_round_blocksize(void *addr, int blk) {
+toccata_round_blocksize(void *addr, int blk,
+                       int mode, const audio_params_t *param)
+{
        int ret;
 
        ret = blk > 512 ? 512 : (blk & -4);
diff -r cb430a99183a -r 9ab014c597e1 sys/arch/arm/iomd/files.iomd
--- a/sys/arch/arm/iomd/files.iomd      Mon Jan 10 21:43:08 2005 +0000
+++ b/sys/arch/arm/iomd/files.iomd      Mon Jan 10 22:01:36 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.iomd,v 1.13 2004/03/13 19:20:50 bjh21 Exp $
+#      $NetBSD: files.iomd,v 1.14 2005/01/10 22:01:36 kent Exp $
 #
 # IOMD-specific configuration data
 #
@@ -58,7 +58,7 @@
 file   arch/arm/iomd/vidcvideo.c               vidcvideo       needs-flag
 
 # Audio device
-device vidcaudio: audiobus, mulaw, aurateconv, audiobell
+device vidcaudio: audiobus, auconv, mulaw, aurateconv, audiobell
 attach vidcaudio at vidc
 file   arch/arm/iomd/vidcaudio.c               vidcaudio       needs-flag
 
diff -r cb430a99183a -r 9ab014c597e1 sys/arch/arm/iomd/vidcaudio.c
--- a/sys/arch/arm/iomd/vidcaudio.c     Mon Jan 10 21:43:08 2005 +0000
+++ b/sys/arch/arm/iomd/vidcaudio.c     Mon Jan 10 22:01:36 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vidcaudio.c,v 1.40 2004/10/29 12:57:16 yamt Exp $      */
+/*     $NetBSD: vidcaudio.c,v 1.41 2005/01/10 22:01:36 kent Exp $      */
 
 /*
  * Copyright (c) 1995 Melvin Tang-Richardson
@@ -65,7 +65,7 @@
 
 #include <sys/param.h> /* proc.h */
 
-__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.40 2004/10/29 12:57:16 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.41 2005/01/10 22:01:36 kent Exp $");
 



Home | Main Index | Thread Index | Old Index