Source-Changes-HG archive

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

[src/kent-audio1]: src/sys/dev * adopt the filter pipeline framework



details:   https://anonhg.NetBSD.org/src/rev/711072f1181e
branches:  kent-audio1
changeset: 571724:711072f1181e
user:      kent <kent%NetBSD.org@localhost>
date:      Mon Jan 03 06:37:57 2005 +0000

description:
* adopt the filter pipeline framework

* ic/ad1848.c, isa/ess.c, isa/sbdsp.c
  remove direct call of set_params() for the default encoding.
  It should be called by the MI audio framework.

diffstat:

 sys/dev/ic/ad1848.c       |   49 ++++++++++------
 sys/dev/ic/ad1848var.h    |    9 +-
 sys/dev/ic/interwave.c    |   51 +++++++++++------
 sys/dev/ic/interwavevar.h |   13 ++--
 sys/dev/isa/ad1848_isa.c  |   17 ++---
 sys/dev/isa/ad1848var.h   |    8 +-
 sys/dev/isa/aria.c        |   42 ++++++++++-----
 sys/dev/isa/ess.c         |  128 +++++++++++++++++++--------------------------
 sys/dev/isa/gus.c         |   54 ++++++++++++++-----
 sys/dev/isa/sb.c          |    6 +-
 sys/dev/isa/sbdsp.c       |  109 +++++++++++++++++++++++----------------
 sys/dev/isa/sbdspvar.h    |    9 +-
 12 files changed, 280 insertions(+), 215 deletions(-)

diffs (truncated from 1200 to 300 lines):

diff -r 554197da48c1 -r 711072f1181e sys/dev/ic/ad1848.c
--- a/sys/dev/ic/ad1848.c       Sun Jan 02 20:03:40 2005 +0000
+++ b/sys/dev/ic/ad1848.c       Mon Jan 03 06:37:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ad1848.c,v 1.18 2004/08/24 00:53:28 thorpej Exp $      */
+/*     $NetBSD: ad1848.c,v 1.18.2.1 2005/01/03 06:37:57 kent Exp $     */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ad1848.c,v 1.18 2004/08/24 00:53:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ad1848.c,v 1.18.2.1 2005/01/03 06:37:57 kent Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -369,7 +369,6 @@
        int i;
        static struct ad1848_volume vol_mid = {220, 220};
        static struct ad1848_volume vol_0   = {0, 0};
-       struct audio_params pparams, rparams;
        int timeout;
 
        /* Initialize the ad1848... */
@@ -393,10 +392,6 @@
        }
        ad1848_reset(sc);
 
-       pparams = audio_default;
-       rparams = audio_default;
-       ad1848_set_params(sc, AUMODE_RECORD|AUMODE_PLAY, 0, &pparams, &rparams);
-
        /* Set default gains */
        ad1848_set_rec_gain(sc, &vol_mid);
        ad1848_set_channel_gain(sc, AD1848_DAC_CHANNEL, &vol_mid);
@@ -856,23 +851,28 @@
 }
 
 int
-ad1848_set_params(void *addr, int setmode, int usemode, struct audio_params *p,
-    struct audio_params *r)
+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)
 {
+       audio_params_t phw, rhw;
        struct ad1848_softc *sc = addr;
        int error, bits, enc;
-       void (*pswcode)(void *, u_char *buf, int cnt);
-       void (*rswcode)(void *, u_char *buf, int cnt);
+       stream_filter_factory_t *pswcode;
+       stream_filter_factory_t *rswcode;
 
-       DPRINTF(("ad1848_set_params: %d %d %d %ld\n",
+       DPRINTF(("ad1848_set_params: %u %u %u %u\n",
                 p->encoding, p->precision, p->channels, p->sample_rate));
 
        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;
@@ -883,13 +883,17 @@
 #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;
-                       pswcode = rswcode = change_sign16_le;
+                       phw.encoding = AUDIO_ENCODING_SLINEAR_LE;
+                       rhw.encoding = AUDIO_ENCODING_SLINEAR_LE;
+                       pswcode = rswcode = change_sign16;
                }
                break;
        case AUDIO_ENCODING_ULINEAR_BE:
@@ -900,11 +904,15 @@
 #endif
                                ) {
                                enc = AUDIO_ENCODING_SLINEAR_LE;
-                               pswcode = swap_bytes_change_sign16_le;
-                               rswcode = change_sign16_swap_bytes_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;
-                               pswcode = rswcode = change_sign16_be;
+                               phw.encoding = AUDIO_ENCODING_SLINEAR_BE;
+                               rhw.encoding = AUDIO_ENCODING_SLINEAR_BE;
+                               pswcode = rswcode = change_sign16;
                        }
                }
                break;
@@ -947,9 +955,12 @@
        error = ad1848_set_speed(sc, &p->sample_rate);
        if (error)
                return error;
+       phw.sample_rate = p->sample_rate;
 
-       p->sw_code = pswcode;
-       r->sw_code = rswcode;
+       if (pswcode != NULL)
+               stream_filter_list_append(pfil, pswcode, &phw);
+       if (rswcode != NULL)
+               stream_filter_list_append(rfil, rswcode, &rhw);
 
        sc->format_bits = bits;
        sc->channels = p->channels;
@@ -1165,7 +1176,7 @@
 }
 
 int
-ad1848_set_speed(struct ad1848_softc *sc, u_long *argp)
+ad1848_set_speed(struct ad1848_softc *sc, u_int *argp)
 {
        /*
         * The sampling speed is encoded in the least significant nible of I8.
diff -r 554197da48c1 -r 711072f1181e sys/dev/ic/ad1848var.h
--- a/sys/dev/ic/ad1848var.h    Sun Jan 02 20:03:40 2005 +0000
+++ b/sys/dev/ic/ad1848var.h    Mon Jan 03 06:37:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ad1848var.h,v 1.10 2002/08/26 17:00:42 martin Exp $    */
+/*     $NetBSD: ad1848var.h,v 1.10.10.1 2005/01/03 06:37:57 kent Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -175,11 +175,12 @@
                                   int, mixer_ctrl_t *));
 int    ad1848_mixer_set_port __P((struct ad1848_softc *, ad1848_devmap_t *,
                                   int, mixer_ctrl_t *));
-int    ad1848_set_speed __P((struct ad1848_softc *, u_long *));
+int    ad1848_set_speed __P((struct ad1848_softc *, u_int *));
 void   ad1848_mute_wave_output __P((struct ad1848_softc *, int, int));
 int    ad1848_query_encoding __P((void *, struct audio_encoding *));
-int    ad1848_set_params __P((void *, int, int, struct audio_params *,
-                              struct audio_params *));
+int    ad1848_set_params __P((void *, int, int, audio_params_t *,
+                              audio_params_t *, stream_filter_list_t *,
+                              stream_filter_list_t *));
 int    ad1848_round_blocksize __P((void *, int));
 int    ad1848_commit_settings __P((void *));
 int    ad1848_set_rec_port __P((struct ad1848_softc *, int));
diff -r 554197da48c1 -r 711072f1181e sys/dev/ic/interwave.c
--- a/sys/dev/ic/interwave.c    Sun Jan 02 20:03:40 2005 +0000
+++ b/sys/dev/ic/interwave.c    Mon Jan 03 06:37:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: interwave.c,v 1.23 2004/07/09 02:46:44 mycroft Exp $   */
+/*     $NetBSD: interwave.c,v 1.23.2.1 2005/01/03 06:37:57 kent Exp $  */
 
 /*
  * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.23 2004/07/09 02:46:44 mycroft Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.23.2.1 2005/01/03 06:37:57 kent Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -715,33 +715,38 @@
 
 
 int
-iw_set_params(addr, setmode, usemode, p, q)
+iw_set_params(addr, setmode, usemode, p, q, pfil, rfil)
        void    *addr;
        int     setmode;
        int     usemode;
-       struct  audio_params *p;
-       struct  audio_params *q;
+       audio_params_t *p;
+       audio_params_t *q;
+       stream_filter_list_t *pfil;
+       stream_filter_list_t *rfil;
 {
+       audio_params_t phw, rhw;
        struct  iw_softc *sc = addr;
-       void    (*swcode)__P((void *, u_char * buf, int cnt)) = NULL;
-       int     factor = 1;
+       stream_filter_factory_t *swcode = NULL;
+
        DPRINTF(("iw_setparams: code %d, prec %d, rate %d, chan %d\n",
                (int) p->encoding, (int) p->precision, (int) p->sample_rate,
                (int) p->channels));
-
-
+       phw = *p;
+       rhw = *q;
        switch (p->encoding) {
        case AUDIO_ENCODING_ULAW:
                if (p->precision != 8)
                        return EINVAL;
-               swcode = setmode & AUMODE_PLAY ? mulaw_to_ulinear8 : ulinear8_to_mulaw;
-               factor = 1;
+               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;
-               swcode = setmode & AUMODE_PLAY ? alaw_to_ulinear8 : ulinear8_to_alaw;
-               factor = 1;
+               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)
@@ -763,13 +768,18 @@
 
        if (setmode & AUMODE_PLAY) {
                sc->play_channels = p->channels;
-               sc->play_encoding = p->encoding;
+               sc->play_encoding = p->encoding;
                sc->play_precision = p->precision;
-               p->factor = factor;
-               p->sw_code = swcode;
                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;
+                       /* stream_filter_list_append(pfil, swcode, &phw); */
+                       pfil->filters[0].factory = swcode;
+                       pfil->filters[0].param = phw;
+                       pfil->req_size = 1;
+               }
        } else {
 #if 0
                q->channels = sc->rec_channels = p->channels;
@@ -779,12 +789,17 @@
                sc->rec_channels = q->channels;
                sc->rec_encoding = q->encoding;
                sc->rec_precision = q->precision;
-               q->factor = factor;
-               q->sw_code = swcode;
 
                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;
+                       /* stream_filter_list_append(rfil, swcode, &rhw); */
+                       rfil->filters[0].factory = swcode;
+                       rfil->filters[0].param = rhw;
+                       rfil->req_size = 1;
+               }
        }
        return 0;
 }
diff -r 554197da48c1 -r 711072f1181e sys/dev/ic/interwavevar.h
--- a/sys/dev/ic/interwavevar.h Sun Jan 02 20:03:40 2005 +0000
+++ b/sys/dev/ic/interwavevar.h Mon Jan 03 06:37:57 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: interwavevar.h,v 1.12 2004/10/29 12:57:17 yamt Exp $   */
+/*     $NetBSD: interwavevar.h,v 1.12.2.1 2005/01/03 06:37:57 kent Exp $       */
 
 /*
  * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
@@ -206,7 +206,8 @@
        /* Encoding. */
        /* XXX should we have separate in/out? */
 int     iw_query_encoding __P((void *, struct audio_encoding *));
-int     iw_set_params __P((void *, int, int, struct audio_params *,  struct audio_params *));
+int     iw_set_params __P((void *, int, int, audio_params_t *, audio_params_t *,
+                          stream_filter_list_t *, stream_filter_list_t *));
 
        /* Hardware may have some say in the blocksize to choose */
 int     iw_round_blocksize __P((void *, int));
@@ -219,12 +220,12 @@
 
        /* Start input/output routines. These usually control DMA. */
 int     iw_start_output __P((void *, void *, int,
-                                   void (*)(void *), void *));
+                            void (*)(void *), void *));
 int     iw_start_input __P((void *, void *, int,
-                                  void (*)(void *), void *));
+                           void (*)(void *), void *));
 
-int     iw_init_input __P((void *,void *,int));
-int     iw_init_output __P((void *,void *,int));
+int     iw_init_input __P((void *, void *, int));



Home | Main Index | Thread Index | Old Index