Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/6c4a559c143b
branches:  isaki-audio2
changeset: 998493:6c4a559c143b
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sat Apr 27 05:22:28 2019 +0000

description:
Adapt to audio2.

diffstat:

 sys/arch/arm/sunxi/sunxi_codec.c |  89 ++++-------------------------------
 sys/arch/arm/sunxi/sunxi_codec.h |   3 +-
 sys/arch/arm/sunxi/sunxi_i2s.c   |  99 +++++++--------------------------------
 3 files changed, 30 insertions(+), 161 deletions(-)

diffs (truncated from 369 to 300 lines):

diff -r 496556a9251f -r 6c4a559c143b sys/arch/arm/sunxi/sunxi_codec.c
--- a/sys/arch/arm/sunxi/sunxi_codec.c  Thu Apr 25 14:00:20 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_codec.c  Sat Apr 27 05:22:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_codec.c,v 1.5 2018/04/20 18:07:40 bouyer Exp $ */
+/* $NetBSD: sunxi_codec.c,v 1.5.4.1 2019/04/27 05:30:37 isaki Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_ddb.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_codec.c,v 1.5 2018/04/20 18:07:40 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_codec.c,v 1.5.4.1 2019/04/27 05:30:37 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -40,7 +40,6 @@
 
 #include <sys/audioio.h>
 #include <dev/audio_if.h>
-#include <dev/auconv.h>
 
 #include <dev/fdt/fdtvar.h>
 
@@ -163,48 +162,18 @@
 }
 
 static int
-sunxi_codec_open(void *priv, int flags)
-{
-       return 0;
-}
-
-static void
-sunxi_codec_close(void *priv)
-{
-}
-
-static int
-sunxi_codec_query_encoding(void *priv, struct audio_encoding *ae)
+sunxi_codec_query_format(void *priv, audio_format_query_t *afp)
 {
        struct sunxi_codec_softc * const sc = priv;
 
-       return auconv_query_encoding(sc->sc_encodings, ae);
+       return audio_query_format(&sc->sc_format, 1, afp);
 }
 
 static int
-sunxi_codec_set_params(void *priv, int setmode, int usemode,
-    audio_params_t *play, audio_params_t *rec,
-    stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+sunxi_codec_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)
 {
-       struct sunxi_codec_softc * const sc = priv;
-       int index;
-
-       if (play && (setmode & AUMODE_PLAY)) {
-               index = auconv_set_converter(&sc->sc_format, 1,
-                   AUMODE_PLAY, play, true, pfil);
-               if (index < 0)
-                       return EINVAL;
-               sc->sc_pchan.ch_params = pfil->req_size > 0 ?
-                   pfil->filters[0].param : *play;
-       }
-       if (rec && (setmode & AUMODE_RECORD)) {
-               index = auconv_set_converter(&sc->sc_format, 1,
-                   AUMODE_RECORD, rec, true, rfil);
-               if (index < 0)
-                       return EINVAL;
-               sc->sc_rchan.ch_params = rfil->req_size > 0 ?
-                   rfil->filters[0].param : *rec;
-       }
 
        return 0;
 }
@@ -270,24 +239,6 @@
                }
 }
 
-static paddr_t
-sunxi_codec_mappage(void *priv, void *addr, off_t off, int prot)
-{
-       struct sunxi_codec_softc * const sc = priv;
-       struct sunxi_codec_dma *dma;
-
-       if (off < 0)
-               return -1;
-
-       LIST_FOREACH(dma, &sc->sc_dmalist, dma_list)
-               if (dma->dma_addr == addr) {
-                       return bus_dmamem_mmap(sc->sc_dmat, dma->dma_segs,
-                           dma->dma_nsegs, off, prot, BUS_DMA_WAITOK);
-               }
-
-       return -1;
-}
-
 static int
 sunxi_codec_getdev(void *priv, struct audio_device *adev)
 {
@@ -319,12 +270,6 @@
        return bs;
 }
 
-static size_t
-sunxi_codec_round_buffersize(void *priv, int dir, size_t bufsize)
-{
-       return bufsize;
-}
-
 static int
 sunxi_codec_trigger_output(void *priv, void *start, void *end, int blksize,
     void (*intr)(void *), void *intrarg, const audio_params_t *params)
@@ -521,21 +466,16 @@
 }
 
 static const struct audio_hw_if sunxi_codec_hw_if = {
-       .open = sunxi_codec_open,
-       .close = sunxi_codec_close,
-       .drain = NULL,
-       .query_encoding = sunxi_codec_query_encoding,
-       .set_params = sunxi_codec_set_params,
+       .query_format = sunxi_codec_query_format,
+       .set_format = sunxi_codec_set_format,
        .allocm = sunxi_codec_allocm,
        .freem = sunxi_codec_freem,
-       .mappage = sunxi_codec_mappage,
        .getdev = sunxi_codec_getdev,
        .set_port = sunxi_codec_set_port,
        .get_port = sunxi_codec_get_port,
        .query_devinfo = sunxi_codec_query_devinfo,
        .get_props = sunxi_codec_get_props,
        .round_blocksize = sunxi_codec_round_blocksize,
-       .round_buffersize = sunxi_codec_round_buffersize,
        .trigger_output = sunxi_codec_trigger_output,
        .trigger_input = sunxi_codec_trigger_input,
        .halt_output = sunxi_codec_halt_output,
@@ -656,7 +596,6 @@
        bus_addr_t addr;
        bus_size_t size;
        uint32_t val;
-       int error;
 
        if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
                aprint_error(": couldn't get registers\n");
@@ -709,14 +648,8 @@
        sc->sc_format.precision = 16;
        sc->sc_format.channels = 2;
        sc->sc_format.channel_mask = AUFMT_STEREO;
-       sc->sc_format.frequency_type = 0;
-       sc->sc_format.frequency[0] = sc->sc_format.frequency[1] = 48000;
-
-       error = auconv_create_encodings(&sc->sc_format, 1, &sc->sc_encodings);
-       if (error) {
-               aprint_error_dev(self, "couldn't create encodings\n");
-               return;
-       }
+       sc->sc_format.frequency_type = 1;
+       sc->sc_format.frequency[0] = 48000;
 
        audio_attach_mi(&sunxi_codec_hw_if, sc, self);
 }
diff -r 496556a9251f -r 6c4a559c143b sys/arch/arm/sunxi/sunxi_codec.h
--- a/sys/arch/arm/sunxi/sunxi_codec.h  Thu Apr 25 14:00:20 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_codec.h  Sat Apr 27 05:22:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_codec.h,v 1.4 2017/10/07 21:53:16 jmcneill Exp $ */
+/* $NetBSD: sunxi_codec.h,v 1.4.8.1 2019/04/27 05:30:37 isaki Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -112,7 +112,6 @@
        kmutex_t                sc_intr_lock;
 
        struct audio_format     sc_format;
-       struct audio_encoding_set *sc_encodings;
 
        struct sunxi_codec_chan sc_pchan;
        struct sunxi_codec_chan sc_rchan;
diff -r 496556a9251f -r 6c4a559c143b sys/arch/arm/sunxi/sunxi_i2s.c
--- a/sys/arch/arm/sunxi/sunxi_i2s.c    Thu Apr 25 14:00:20 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_i2s.c    Sat Apr 27 05:22:28 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_i2s.c,v 1.3 2018/11/17 20:36:23 jmcneill Exp $ */
+/* $NetBSD: sunxi_i2s.c,v 1.3.2.1 2019/04/27 05:22:28 isaki Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c,v 1.3 2018/11/17 20:36:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_i2s.c,v 1.3.2.1 2019/04/27 05:22:28 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -38,7 +38,7 @@
 
 #include <sys/audioio.h>
 #include <dev/audio_if.h>
-#include <dev/auconv.h>
+#include <dev/audio/linear.h>
 
 #include <dev/fdt/fdtvar.h>
 
@@ -159,7 +159,6 @@
        kmutex_t                sc_intr_lock;
 
        struct audio_format     sc_format;
-       struct audio_encoding_set *sc_encodings;
 
        struct sunxi_i2s_chan   sc_pchan;
        struct sunxi_i2s_chan   sc_rchan;
@@ -234,51 +233,24 @@
 }
 
 static int
-sunxi_i2s_open(void *priv, int flags)
-{
-       return 0;
-}
-
-static void
-sunxi_i2s_close(void *priv)
-{
-}
-
-static int
-sunxi_i2s_query_encoding(void *priv, struct audio_encoding *ae)
+sunxi_i2s_query_format(void *priv, audio_format_query_t *afp)
 {
        struct sunxi_i2s_softc * const sc = priv;
 
-       return auconv_query_encoding(sc->sc_encodings, ae);
+       return audio_query_format(&sc->sc_format, 1, afp);
 }
 
 static int
-sunxi_i2s_set_params(void *priv, int setmode, int usemode,
-    audio_params_t *play, audio_params_t *rec,
-    stream_filter_list_t *pfil, stream_filter_list_t *rfil)
+sunxi_i2s_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)
 {
-       struct sunxi_i2s_softc * const sc = priv;
-       int index;
 
-       if (play && (setmode & AUMODE_PLAY)) {
-               index = auconv_set_converter(&sc->sc_format, 1,
-                   AUMODE_PLAY, play, true, pfil);
-               if (index < 0)
-                       return EINVAL;
-               sc->sc_pchan.ch_params = pfil->req_size > 0 ?
-                   pfil->filters[0].param : *play;
-               pfil->prepend(pfil, linear16_16_to_linear32,
-                   &sc->sc_pchan.ch_params);
+       if ((setmode & AUMODE_PLAY)) {
+               pfil->codec = audio_internal_to_linear32;
        }
-       if (rec && (setmode & AUMODE_RECORD)) {
-               index = auconv_set_converter(&sc->sc_format, 1,
-                   AUMODE_RECORD, rec, true, rfil);
-               if (index < 0)
-                       return EINVAL;
-               sc->sc_rchan.ch_params = rfil->req_size > 0 ?
-                   rfil->filters[0].param : *rec;
-               rfil->prepend(rfil, linear32_32_to_linear16,
-                   &sc->sc_rchan.ch_params);
+       if ((setmode & AUMODE_RECORD)) {
+               rfil->codec = audio_linear32_to_internal;
        }
 
        return 0;
@@ -321,24 +293,6 @@
                }
 }
 
-static paddr_t
-sunxi_i2s_mappage(void *priv, void *addr, off_t off, int prot)
-{
-       struct sunxi_i2s_softc * const sc = priv;
-       struct sunxi_i2s_dma *dma;
-
-       if (off < 0)
-               return -1;
-
-       LIST_FOREACH(dma, &sc->sc_dmalist, dma_list)
-               if (dma->dma_addr == addr) {
-                       return bus_dmamem_mmap(sc->sc_dmat, dma->dma_segs,
-                           dma->dma_nsegs, off, prot, BUS_DMA_WAITOK);
-               }
-
-       return -1;



Home | Main Index | Thread Index | Old Index