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/e2036fc25e78
branches:  isaki-audio2
changeset: 450861:e2036fc25e78
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sat Apr 27 12:57:54 2019 +0000

description:
Adapt to audio2.

diffstat:

 sys/dev/pci/auacer.c |  93 ++++++++++++---------------------------------------
 1 files changed, 22 insertions(+), 71 deletions(-)

diffs (209 lines):

diff -r 1e321097c930 -r e2036fc25e78 sys/dev/pci/auacer.c
--- a/sys/dev/pci/auacer.c      Sat Apr 27 12:53:37 2019 +0000
+++ b/sys/dev/pci/auacer.c      Sat Apr 27 12:57:54 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: auacer.c,v 1.36.2.1 2019/04/21 05:11:22 isaki Exp $    */
+/*     $NetBSD: auacer.c,v 1.36.2.2 2019/04/27 12:57:54 isaki Exp $    */
 
 /*-
  * Copyright (c) 2004, 2008 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auacer.c,v 1.36.2.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auacer.c,v 1.36.2.2 2019/04/27 12:57:54 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -60,8 +60,6 @@
 
 #include <sys/audioio.h>
 #include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
 
 #include <sys/bus.h>
 
@@ -128,7 +126,6 @@
 
 #define AUACER_NFORMATS        3
        struct audio_format sc_formats[AUACER_NFORMATS];
-       struct audio_encoding_set *sc_encodings;
 };
 
 #define READ1(sc, a) bus_space_read_1(sc->iot, sc->aud_ioh, a)
@@ -153,10 +150,10 @@
 
 static int     auacer_intr(void *);
 
-static int     auacer_query_encoding(void *, struct audio_encoding *);
-static int     auacer_set_params(void *, int, int, audio_params_t *,
-                                 audio_params_t *, stream_filter_list_t *,
-                                 stream_filter_list_t *);
+static int     auacer_query_format(void *, audio_format_query_t *);
+static int     auacer_set_format(void *, int,
+                                const audio_params_t *, const audio_params_t *,
+                                audio_filter_reg_t *, audio_filter_reg_t *);
 static int     auacer_round_blocksize(void *, int, int,
                                       const audio_params_t *);
 static int     auacer_halt_output(void *);
@@ -168,7 +165,6 @@
 static void    *auacer_allocm(void *, int, size_t);
 static void    auacer_freem(void *, void *, size_t);
 static size_t  auacer_round_buffersize(void *, int, size_t);
-static paddr_t auacer_mappage(void *, void *, off_t, int);
 static int     auacer_get_props(void *);
 static int     auacer_trigger_output(void *, void *, void *, int,
                                      void (*)(void *), void *,
@@ -190,8 +186,8 @@
 static void auacer_reset(struct auacer_softc *sc);
 
 static const struct audio_hw_if auacer_hw_if = {
-       .query_encoding         = auacer_query_encoding,
-       .set_params             = auacer_set_params,
+       .query_format           = auacer_query_format,
+       .set_format             = auacer_set_format,
        .round_blocksize        = auacer_round_blocksize,
        .halt_output            = auacer_halt_output,
        .halt_input             = auacer_halt_input,
@@ -202,7 +198,6 @@
        .allocm                 = auacer_allocm,
        .freem                  = auacer_freem,
        .round_buffersize       = auacer_round_buffersize,
-       .mappage                = auacer_mappage,
        .get_props              = auacer_get_props,
        .trigger_output         = auacer_trigger_output,
        .trigger_input          = auacer_trigger_input,
@@ -219,8 +214,9 @@
                .precision      = 16, \
                .channels       = (ch), \
                .channel_mask   = (chmask), \
-               .frequency_type = 0, \
-               .frequency      = { 8000, 48000 }, \
+               .frequency_type = 9, \
+               .frequency      = {  8000, 11025, 12000, 16000, 22050, \
+                                   24000, 32000, 44100, 48000, }, \
        }
 static const struct audio_format auacer_formats[AUACER_NFORMATS] = {
        AUACER_FORMAT(AUMODE_PLAY | AUMODE_RECORD, 2, AUFMT_STEREO),
@@ -342,16 +338,7 @@
                        sc->sc_formats[i].frequency[0] = 48000;
                }
        }
-       mutex_exit(&sc->sc_lock);
 
-       if (0 != auconv_create_encodings(sc->sc_formats, AUACER_NFORMATS,
-                                        &sc->sc_encodings)) {
-               mutex_destroy(&sc->sc_lock);
-               mutex_destroy(&sc->sc_intr_lock);
-               return;
-       }
-
-       mutex_enter(&sc->sc_lock);
        mutex_spin_enter(&sc->sc_intr_lock);
        auacer_reset(sc);
        mutex_spin_exit(&sc->sc_intr_lock);
@@ -500,13 +487,13 @@
 }
 
 static int
-auacer_query_encoding(void *v, struct audio_encoding *aep)
+auacer_query_format(void *v, audio_format_query_t *afp)
 {
        struct auacer_softc *sc;
 
-       DPRINTF(ALI_DEBUG_API, ("auacer_query_encoding\n"));
+       DPRINTF(ALI_DEBUG_API, ("%s\n", __func__));
        sc = v;
-       return auconv_query_encoding(sc->sc_encodings, aep);
+       return audio_query_format(sc->sc_formats, AUACER_NFORMATS, afp);
 }
 
 static int
@@ -537,17 +524,16 @@
 }
 
 static int
-auacer_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)
+auacer_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 auacer_softc *sc;
-       struct audio_params *p;
-       stream_filter_list_t *fil;
+       const audio_params_t *p;
        uint32_t control;
        int mode, index;
 
-       DPRINTF(ALI_DEBUG_API, ("auacer_set_params\n"));
+       DPRINTF(ALI_DEBUG_API, ("%s\n", __func__));
        sc = v;
        for (mode = AUMODE_RECORD; mode != -1;
             mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
@@ -555,27 +541,9 @@
                        continue;
 
                p = mode == AUMODE_PLAY ? play : rec;
-               if (p == NULL)
-                       continue;
 
-               if ((p->sample_rate !=  8000) &&
-                   (p->sample_rate != 11025) &&
-                   (p->sample_rate != 12000) &&
-                   (p->sample_rate != 16000) &&
-                   (p->sample_rate != 22050) &&
-                   (p->sample_rate != 24000) &&
-                   (p->sample_rate != 32000) &&
-                   (p->sample_rate != 44100) &&
-                   (p->sample_rate != 48000))
-                       return (EINVAL);
-
-               fil = mode == AUMODE_PLAY ? pfil : rfil;
-               index = auconv_set_converter(sc->sc_formats, AUACER_NFORMATS,
-                                            mode, p, TRUE, fil);
-               if (index < 0)
-                       return EINVAL;
-               if (fil->req_size > 0)
-                       p = &fil->filters[0].param;
+               index = audio_indexof_format(sc->sc_formats, AUACER_NFORMATS,
+                   mode, p);
                /* p points HW encoding */
                if (sc->sc_formats[index].frequency_type != 1
                    && auacer_set_rate(sc, mode, p->sample_rate))
@@ -591,7 +559,7 @@
                }
        }
 
-       return (0);
+       return 0;
 }
 
 static int
@@ -741,23 +709,6 @@
        return size;
 }
 
-static paddr_t
-auacer_mappage(void *v, void *mem, off_t off, int prot)
-{
-       struct auacer_softc *sc;
-       struct auacer_dma *p;
-
-       if (off < 0)
-               return -1;
-       sc = v;
-       for (p = sc->sc_dmas; p && KERNADDR(p) != mem; p = p->next)
-               continue;
-       if (p == NULL)
-               return -1;
-       return bus_dmamem_mmap(sc->dmat, p->segs, p->nsegs,
-           off, prot, BUS_DMA_WAITOK);
-}
-
 static int
 auacer_get_props(void *v)
 {



Home | Main Index | Thread Index | Old Index