Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/e15230ee7f63
branches:  isaki-audio2
changeset: 450853:e15230ee7f63
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sat Apr 27 11:52:53 2019 +0000

description:
Adapt to audio2.

diffstat:

 sys/arch/usermode/dev/vaudio.c     |  91 +++++++------------------------------
 sys/arch/usermode/include/thunk.h  |   3 +-
 sys/arch/usermode/usermode/thunk.c |  10 +---
 sys/dev/ic/pl041.c                 |  40 +++++-----------
 sys/dev/ic/pl041var.h              |   4 +-
 5 files changed, 34 insertions(+), 114 deletions(-)

diffs (truncated from 331 to 300 lines):

diff -r 442cc55a9c09 -r e15230ee7f63 sys/arch/usermode/dev/vaudio.c
--- a/sys/arch/usermode/dev/vaudio.c    Sat Apr 27 10:17:59 2019 +0000
+++ b/sys/arch/usermode/dev/vaudio.c    Sat Apr 27 11:52:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vaudio.c,v 1.4.32.1 2019/04/21 05:11:22 isaki Exp $ */
+/* $NetBSD: vaudio.c,v 1.4.32.2 2019/04/27 11:58:02 isaki Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.4.32.1 2019/04/21 05:11:22 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.4.32.2 2019/04/27 11:58:02 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -39,7 +39,6 @@
 #include <machine/thunk.h>
 
 #include <dev/audio_if.h>
-#include <dev/auconv.h>
 
 static const struct audio_format vaudio_audio_formats[1] = {
        {
@@ -53,6 +52,7 @@
                .frequency      = { 8000, 48000 },
        },
 };
+#define VAUDIO_NFORMATS __arraycount(vaudio_audio_formats)
 
 struct vaudio_stream {
        struct vaudio_softc             *st_softc;
@@ -72,7 +72,6 @@
        void *                          sc_audiodev;
        const char *                    sc_audiopath;
        int                             sc_audiofd;
-       struct audio_encoding_set *     sc_encodings;
        audio_params_t                  sc_pparam;
        audio_params_t                  sc_rparam;
        kmutex_t                        sc_lock;
@@ -90,13 +89,10 @@
 static void    vaudio_softintr_play(void *);
 static void    vaudio_softintr_record(void *);
 
-static int     vaudio_open(void *, int);
-static void    vaudio_close(void *);
-static int     vaudio_drain(void *);
-static int     vaudio_query_encoding(void *, audio_encoding_t *);
-static int     vaudio_set_params(void *, int, int, audio_params_t *,
-                                 audio_params_t *, stream_filter_list_t *,
-                                 stream_filter_list_t *);
+static int     vaudio_query_format(void *, audio_format_query_t *);
+static int     vaudio_set_format(void *, int, const audio_params_t *,
+                                 const audio_params_t *,
+                                 audio_filter_reg_t *, audio_filter_reg_t *);
 static int     vaudio_commit_settings(void *);
 static int     vaudio_trigger_output(void *, void *, void *, int,
                                      void (*)(void *), void *,
@@ -117,11 +113,8 @@
     vaudio_match, vaudio_attach, NULL, NULL);
 
 static const struct audio_hw_if vaudio_hw_if = {
-       .open = vaudio_open,
-       .close = vaudio_close,
-       .drain = vaudio_drain,
-       .query_encoding = vaudio_query_encoding,
-       .set_params = vaudio_set_params,
+       .query_format = vaudio_query_format,
+       .set_format = vaudio_set_format,
        .commit_settings = vaudio_commit_settings,
        .halt_output = vaudio_halt_output,
        .halt_input = vaudio_halt_input,
@@ -151,7 +144,6 @@
 {
        struct vaudio_softc *sc = device_private(self);
        struct thunkbus_attach_args *taa = opaque;
-       int error;
 
        aprint_naive("\n");
        aprint_normal(": Virtual Audio (device = %s)\n", taa->u.vaudio.device);
@@ -171,13 +163,6 @@
        mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
        mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_AUDIO);
 
-       error = auconv_create_encodings(vaudio_audio_formats,
-           __arraycount(vaudio_audio_formats), &sc->sc_encodings);
-       if (error) {
-               aprint_error_dev(self, "couldn't create encodings\n");
-               return;
-       }
-
        sc->sc_play.st_softc = sc;
        sc->sc_play.st_sih = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE,
            vaudio_softintr_play, &sc->sc_play);
@@ -259,63 +244,23 @@
 }
 
 static int
-vaudio_open(void *opaque, int flags)
+vaudio_query_format(void *opaque, audio_format_query_t *afp)
 {
-       return 0;
-}
-
-static void
-vaudio_close(void *opaque)
-{
-}
 
-static int
-vaudio_drain(void *opaque)
-{
-       struct vaudio_softc *sc = opaque;
-
-       return thunk_audio_drain(sc->sc_audiofd);
-}
-
-static int
-vaudio_query_encoding(void *opaque, audio_encoding_t *enc)
-{
-       struct vaudio_softc *sc = opaque;
-
-       return auconv_query_encoding(sc->sc_encodings, enc);
+       return audio_query_format(vaudio_audio_formats, VAUDIO_NFORMATS, afp);
 }
 
 static int
-vaudio_set_params(void *opaque, int setmode, int usemode,
-    audio_params_t *play, audio_params_t *rec,
-    stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+vaudio_set_format(void *opaque, int setmode,
+    const audio_params_t *play, const audio_params_t *rec,
+    audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
        struct vaudio_softc *sc = opaque;
-       audio_params_t *p;
-       stream_filter_list_t *fil;
-       int mode, index;
 
-       for (mode = AUMODE_RECORD; mode != -1;
-           mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
-               if ((setmode & mode) == 0)
-                       continue;
-               p = mode == AUMODE_PLAY ? play : rec;
-               fil = mode == AUMODE_PLAY ? pfil : rfil;
-               if (p == NULL)
-                       continue;
-
-               index = auconv_set_converter(vaudio_audio_formats,
-                   __arraycount(vaudio_audio_formats), mode, p, TRUE, fil);
-               if (index < 0)
-                       return EINVAL;
-               if (fil->req_size > 0)
-                       p = &fil->filters[0].param;
-
-               if (mode == AUMODE_PLAY)
-                       sc->sc_pparam = *p;
-               else
-                       sc->sc_rparam = *p;
-       }
+       if ((setmode & AUMODE_PLAY))
+               sc->sc_pparam = *play;
+       if ((setmode & AUMODE_RECORD))
+               sc->sc_rparam = *rec;
 
        return 0;
 }
diff -r 442cc55a9c09 -r e15230ee7f63 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Sat Apr 27 10:17:59 2019 +0000
+++ b/sys/arch/usermode/include/thunk.h Sat Apr 27 11:52:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.66 2018/08/01 09:46:46 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.66.2.1 2019/04/27 11:58:02 isaki Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -185,7 +185,6 @@
 
 int    thunk_audio_open(const char *);
 int    thunk_audio_close(int);
-int    thunk_audio_drain(int);
 int    thunk_audio_config(int, const thunk_audio_config_t *,
                           const thunk_audio_config_t *);
 int    thunk_audio_pollout(int);
diff -r 442cc55a9c09 -r e15230ee7f63 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Sat Apr 27 10:17:59 2019 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Sat Apr 27 11:52:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.91 2018/08/01 09:44:31 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.91.2.1 2019/04/27 11:58:02 isaki Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.91 2018/08/01 09:44:31 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.91.2.1 2019/04/27 11:58:02 isaki Exp $");
 #endif
 
 #define _KMEMUSER
@@ -912,12 +912,6 @@
 }
 
 int
-thunk_audio_drain(int fd)
-{
-       return ioctl(fd, AUDIO_DRAIN, 0);
-}
-
-int
 thunk_audio_config(int fd, const thunk_audio_config_t *pconf,
     const thunk_audio_config_t *rconf)
 {
diff -r 442cc55a9c09 -r e15230ee7f63 sys/dev/ic/pl041.c
--- a/sys/dev/ic/pl041.c        Sat Apr 27 10:17:59 2019 +0000
+++ b/sys/dev/ic/pl041.c        Sat Apr 27 11:52:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pl041.c,v 1.5 2018/09/03 16:29:31 riastradh Exp $ */
+/* $NetBSD: pl041.c,v 1.5.2.1 2019/04/27 11:52:53 isaki Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pl041.c,v 1.5 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pl041.c,v 1.5.2.1 2019/04/27 11:52:53 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -37,7 +37,6 @@
 #include <sys/audioio.h>
 
 #include <dev/audio_if.h>
-#include <dev/auconv.h>
 
 #include <dev/ic/ac97var.h>
 #include <dev/ic/ac97reg.h>
@@ -93,8 +92,8 @@
        .precision = 16,
        .channels = 2,
        .channel_mask = AUFMT_STEREO,
-       .frequency_type = 0,
-       .frequency = { 48000, 48000 }
+       .frequency_type = 1,
+       .frequency = { 48000 }
 };
 
 static void
@@ -122,27 +121,19 @@
 }
 
 static int
-aaci_query_encoding(void *priv, struct audio_encoding *enc)
+aaci_query_format(void *priv, audio_format_query_t *afp)
 {
-       struct aaci_softc * const sc = priv;
 
-       return auconv_query_encoding(sc->sc_encodings, enc);
+       return audio_query_format(&aaci_format, 1, afp);
 }
 
 static int
-aaci_set_params(void *priv, int setmode, int usermode,
-    audio_params_t *play, audio_params_t *rec,
-    stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+aaci_set_format(void *priv, int setmode,
+    const audio_params_t *play, const audio_params_t *rec,
+    audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
-       int index;
 
-       if (play && (setmode & AUMODE_PLAY) != 0) {
-               index = auconv_set_converter(&aaci_format, 1, AUMODE_PLAY,
-                   play, true, pfil);
-               if (index < 0)
-                       return EINVAL;
-       }
-
+       /* We have only one format so nothing to do here. */
        return 0;
 }
 
@@ -250,8 +241,8 @@
 }
 
 static const struct audio_hw_if aaci_hw_if = {
-       .query_encoding = aaci_query_encoding,
-       .set_params = aaci_set_params,
+       .query_format = aaci_query_format,
+       .set_format = aaci_set_format,
        .getdev = aaci_getdev,
        .set_port = aaci_set_port,
        .get_port = aaci_get_port,
@@ -322,13 +313,6 @@



Home | Main Index | Thread Index | Old Index