Source-Changes-HG archive

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

[src/isaki-audio2]: src/sys/dev/pci Adapt to audio2.



details:   https://anonhg.NetBSD.org/src/rev/1e321097c930
branches:  isaki-audio2
changeset: 450860:1e321097c930
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sat Apr 27 12:53:37 2019 +0000

description:
Adapt to audio2.
- Correct frequency_type in modem_audio_format.
- {spdif,modem}_audio_format in my previous commit (in this branch)
  was also wrong. :(

diffstat:

 sys/dev/pci/auich.c |  122 ++++++++++++++++++++-------------------------------
 1 files changed, 49 insertions(+), 73 deletions(-)

diffs (246 lines):

diff -r acadaeb06870 -r 1e321097c930 sys/dev/pci/auich.c
--- a/sys/dev/pci/auich.c       Sat Apr 27 12:28:40 2019 +0000
+++ b/sys/dev/pci/auich.c       Sat Apr 27 12:53:37 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: auich.c,v 1.154.2.1 2019/04/21 05:11:22 isaki Exp $    */
+/*     $NetBSD: auich.c,v 1.154.2.2 2019/04/27 12:53:37 isaki Exp $    */
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -111,7 +111,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.154.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.154.2.2 2019/04/27 12:53:37 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -130,8 +130,6 @@
 #include <dev/pci/auichreg.h>
 
 #include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
 
 #include <dev/ic/ac97reg.h>
 #include <dev/ic/ac97var.h>
@@ -231,8 +229,6 @@
 #define AUICH_MODEM_NFORMATS   1
        struct audio_format sc_audio_formats[AUICH_AUDIO_NFORMATS];
        struct audio_format sc_modem_formats[AUICH_MODEM_NFORMATS];
-       struct audio_encoding_set *sc_encodings;
-       struct audio_encoding_set *sc_spdif_encodings;
 
        int sc_cas_been_used;
 };
@@ -259,10 +255,10 @@
 
 static int     auich_open(void *, int);
 static void    auich_close(void *);
-static int     auich_query_encoding(void *, struct audio_encoding *);
-static int     auich_set_params(void *, int, int, audio_params_t *,
-                   audio_params_t *, stream_filter_list_t *,
-                   stream_filter_list_t *);
+static int     auich_query_format(void *, struct audio_format_query *);
+static int     auich_set_format(void *, int,
+                   const audio_params_t *, const audio_params_t *,
+                   audio_filter_reg_t *, audio_filter_reg_t *);
 static int     auich_round_blocksize(void *, int, int, const audio_params_t *);
 static void    auich_halt_pipe(struct auich_softc *, int);
 static int     auich_halt_output(void *);
@@ -274,7 +270,6 @@
 static void    *auich_allocm(void *, int, size_t);
 static void    auich_freem(void *, void *, size_t);
 static size_t  auich_round_buffersize(void *, int, size_t);
-static paddr_t auich_mappage(void *, void *, off_t, int);
 static int     auich_get_props(void *);
 static void    auich_trigger_pipe(struct auich_softc *, int, struct auich_ring *);
 static void    auich_intr_pipe(struct auich_softc *, int, struct auich_ring *);
@@ -307,8 +302,8 @@
 static const struct audio_hw_if auich_hw_if = {
        .open                   = auich_open,
        .close                  = auich_close,
-       .query_encoding         = auich_query_encoding,
-       .set_params             = auich_set_params,
+       .query_format           = auich_query_format,
+       .set_format             = auich_set_format,
        .round_blocksize        = auich_round_blocksize,
        .halt_output            = auich_halt_output,
        .halt_input             = auich_halt_input,
@@ -319,7 +314,6 @@
        .allocm                 = auich_allocm,
        .freem                  = auich_freem,
        .round_buffersize       = auich_round_buffersize,
-       .mappage                = auich_mappage,
        .get_props              = auich_get_props,
        .trigger_output         = auich_trigger_output,
        .trigger_input          = auich_trigger_input,
@@ -348,11 +342,29 @@
 
 #define AUICH_SPDIF_NFORMATS   1
 static const struct audio_format auich_spdif_formats[AUICH_SPDIF_NFORMATS] = {
-       AUICH_FORMAT(AUMODE_PLAY | AUMODE_RECORD, 2, AUFMT_STEREO),
+       {
+               .mode           = AUMODE_PLAY | AUMODE_RECORD,
+               .encoding       = AUDIO_ENCODING_SLINEAR_LE,
+               .validbits      = 16,
+               .precision      = 16,
+               .channels       = 2,
+               .channel_mask   = AUFMT_STEREO,
+               .frequency_type = 1,
+               .frequency      = { 48000 },
+       },
 };
 
 static const struct audio_format auich_modem_formats[AUICH_MODEM_NFORMATS] = {
-       AUICH_FORMAT(AUMODE_PLAY | AUMODE_RECORD, 1, AUFMT_MONAURAL),
+       {
+               .mode           = AUMODE_PLAY | AUMODE_RECORD,
+               .encoding       = AUDIO_ENCODING_SLINEAR_LE,
+               .validbits      = 16,
+               .precision      = 16,
+               .channels       = 1,
+               .channel_mask   = AUFMT_MONAURAL,
+               .frequency_type = 2,
+               .frequency      = { 8000, 16000 },
+       },
 };
 
 #define PCI_ID_CODE0(v, p)     PCI_ID_CODE(PCI_VENDOR_##v, PCI_PRODUCT_##v##_##p)
@@ -636,19 +648,10 @@
                        }
                }
                mutex_exit(&sc->sc_lock);
-               if (0 != auconv_create_encodings(sc->sc_audio_formats,
-                       AUICH_AUDIO_NFORMATS, &sc->sc_encodings))
-                       return;
-               if (0 != auconv_create_encodings(auich_spdif_formats,
-                       AUICH_SPDIF_NFORMATS, &sc->sc_spdif_encodings))
-                       return;
        } else {
                mutex_exit(&sc->sc_lock);
                memcpy(sc->sc_modem_formats, auich_modem_formats,
                    sizeof(auich_modem_formats));
-               if (0 != auconv_create_encodings(sc->sc_modem_formats,
-                       AUICH_MODEM_NFORMATS, &sc->sc_encodings))
-                       return;
        }
 
        /* Watch for power change */
@@ -711,10 +714,6 @@
 
        mutex_enter(&sc->sc_lock);
 
-       /* audio_encoding_set */
-       auconv_delete_encodings(sc->sc_encodings);
-       auconv_delete_encodings(sc->sc_spdif_encodings);
-
        /* ac97 */
        if (sc->codec_if != NULL)
                sc->codec_if->vtbl->detach(sc->codec_if);
@@ -951,13 +950,18 @@
 }
 
 static int
-auich_query_encoding(void *v, struct audio_encoding *aep)
+auich_query_format(void *v, struct audio_format_query *afp)
 {
        struct auich_softc *sc;
 
        sc = (struct auich_softc *)v;
-       return auconv_query_encoding(
-           sc->sc_spdif ? sc->sc_spdif_encodings : sc->sc_encodings, aep);
+       if (sc->sc_spdif) {
+               return audio_query_format(auich_spdif_formats,
+                   AUICH_SPDIF_NFORMATS, afp);
+       } else {
+               return audio_query_format(auich_audio_formats,
+                   AUICH_AUDIO_NFORMATS, afp);
+       }
 }
 
 static int
@@ -987,13 +991,12 @@
 }
 
 static int
-auich_set_params(void *v, int setmode, int usemode,
-    audio_params_t *play, audio_params_t *rec, stream_filter_list_t *pfil,
-    stream_filter_list_t *rfil)
+auich_set_format(void *v, int setmode,
+    const audio_params_t *play, const audio_params_t *rec,
+    audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
        struct auich_softc *sc;
-       audio_params_t *p;
-       stream_filter_list_t *fil;
+       const audio_params_t *p;
        int mode, index;
        uint32_t control;
 
@@ -1004,31 +1007,21 @@
                        continue;
 
                p = mode == AUMODE_PLAY ? play : rec;
-               fil = mode == AUMODE_PLAY ? pfil : rfil;
-               if (p == NULL)
-                       continue;
 
                if (sc->sc_codectype == AC97_CODEC_TYPE_AUDIO) {
-                       if (p->sample_rate <  8000 ||
-                           p->sample_rate > 48000)
-                               return EINVAL;
-
                        if (!sc->sc_spdif)
-                               index = auconv_set_converter(sc->sc_audio_formats,
-                                   AUICH_AUDIO_NFORMATS, mode, p, TRUE, fil);
+                               index = audio_indexof_format(
+                                   sc->sc_audio_formats, AUICH_AUDIO_NFORMATS,
+                                   mode, p);
                        else
-                               index = auconv_set_converter(auich_spdif_formats,
-                                   AUICH_SPDIF_NFORMATS, mode, p, TRUE, fil);
+                               index = audio_indexof_format(
+                                   auich_spdif_formats, AUICH_SPDIF_NFORMATS,
+                                   mode, p);
                } else {
-                       if (p->sample_rate != 8000 && p->sample_rate != 16000)
-                               return EINVAL;
-                       index = auconv_set_converter(sc->sc_modem_formats,
-                           AUICH_MODEM_NFORMATS, mode, p, TRUE, fil);
+                       index = audio_indexof_format(sc->sc_modem_formats,
+                           AUICH_MODEM_NFORMATS, mode, p);
                }
-               if (index < 0)
-                       return EINVAL;
-               if (fil->req_size > 0)
-                       p = &fil->filters[0].param;
+
                /* p represents HW encoding */
                if (sc->sc_codectype == AC97_CODEC_TYPE_AUDIO) {
                        if (sc->sc_audio_formats[index].frequency_type != 1
@@ -1210,23 +1203,6 @@
        return size;
 }
 
-static paddr_t
-auich_mappage(void *v, void *mem, off_t off, int prot)
-{
-       struct auich_softc *sc;
-       struct auich_dma *p;
-
-       if (off < 0)
-               return -1;
-       sc = v;
-       for (p = sc->sc_dmas; p && KERNADDR(p) != mem; p = p->next)
-               continue;
-       if (!p)
-               return -1;
-       return bus_dmamem_mmap(sc->dmat, p->segs, p->nsegs,
-           off, prot, BUS_DMA_WAITOK);
-}
-
 static int
 auich_get_props(void *v)
 {



Home | Main Index | Thread Index | Old Index