Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/sunxi Remove sunxi_codec_drain(). ...



details:   https://anonhg.NetBSD.org/src/rev/7c519217c512
branches:  trunk
changeset: 318396:7c519217c512
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Fri Apr 20 18:07:40 2018 +0000
description:
Remove sunxi_codec_drain(). It's optional, and as the DMA is not stopped
at this time I'm not sure what draining the fifo means here. Also,
we're not waiting for the drain to complete.
The upper level will play enough silence when needed to make sure interesting
data have been played.

In sunxi_codec_halt_output() and sunxi_codec_halt_input(), drain the fifo
(and wait for it to complete) before or after disabling the DMA.

diffstat:

 sys/arch/arm/sunxi/sunxi_codec.c |  39 ++++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 21 deletions(-)

diffs (85 lines):

diff -r 743cfe4a6657 -r 7c519217c512 sys/arch/arm/sunxi/sunxi_codec.c
--- a/sys/arch/arm/sunxi/sunxi_codec.c  Fri Apr 20 18:04:12 2018 +0000
+++ b/sys/arch/arm/sunxi/sunxi_codec.c  Fri Apr 20 18:07:40 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_codec.c,v 1.4 2018/04/19 18:19:17 bouyer Exp $ */
+/* $NetBSD: sunxi_codec.c,v 1.5 2018/04/20 18:07:40 bouyer 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.4 2018/04/19 18:19:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_codec.c,v 1.5 2018/04/20 18:07:40 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -174,21 +174,6 @@
 }
 
 static int
-sunxi_codec_drain(void *priv)
-{
-       struct sunxi_codec_softc * const sc = priv;
-       uint32_t val;
-
-       val = CODEC_READ(sc, AC_DAC_FIFOC(sc));
-       CODEC_WRITE(sc, AC_DAC_FIFOC(sc), val | DAC_FIFOC_FIFO_FLUSH);
-
-       val = CODEC_READ(sc, AC_ADC_FIFOC(sc));
-       CODEC_WRITE(sc, AC_ADC_FIFOC(sc), val | ADC_FIFOC_FIFO_FLUSH);
-
-       return 0;
-}
-
-static int
 sunxi_codec_query_encoding(void *priv, struct audio_encoding *ae)
 {
        struct sunxi_codec_softc * const sc = priv;
@@ -479,6 +464,12 @@
        /* Disable DMA channel */
        fdtbus_dma_halt(ch->ch_dma);
 
+       /* flush fifo */
+       val = CODEC_READ(sc, AC_DAC_FIFOC(sc));
+       CODEC_WRITE(sc, AC_DAC_FIFOC(sc), val | DAC_FIFOC_FIFO_FLUSH);
+       while (val & DAC_FIFOC_FIFO_FLUSH)
+               val = CODEC_READ(sc, AC_DAC_FIFOC(sc));
+
        /* Mute output */
        if (sc->sc_cfg->mute)
                sc->sc_cfg->mute(sc, 1, ch->ch_mode);
@@ -500,13 +491,19 @@
        struct sunxi_codec_chan *ch = &sc->sc_rchan;
        uint32_t val;
 
-       /* Disable DMA channel */
-       fdtbus_dma_halt(ch->ch_dma);
-
        /* Mute output */
        if (sc->sc_cfg->mute)
                sc->sc_cfg->mute(sc, 1, ch->ch_mode);
 
+       /* flush fifo */
+       val = CODEC_READ(sc, AC_ADC_FIFOC(sc));
+       CODEC_WRITE(sc, AC_ADC_FIFOC(sc), val | ADC_FIFOC_FIFO_FLUSH);
+       while (val & ADC_FIFOC_FIFO_FLUSH) 
+               val = CODEC_READ(sc, AC_ADC_FIFOC(sc));
+
+       /* Disable DMA channel */
+       fdtbus_dma_halt(ch->ch_dma);
+
        /* Disable ADC DRQ */
        val = CODEC_READ(sc, AC_ADC_FIFOC(sc));
        CODEC_WRITE(sc, AC_ADC_FIFOC(sc), val & ~ADC_FIFOC_DRQ_EN);
@@ -526,7 +523,7 @@
 static const struct audio_hw_if sunxi_codec_hw_if = {
        .open = sunxi_codec_open,
        .close = sunxi_codec_close,
-       .drain = sunxi_codec_drain,
+       .drain = NULL,
        .query_encoding = sunxi_codec_query_encoding,
        .set_params = sunxi_codec_set_params,
        .allocm = sunxi_codec_allocm,



Home | Main Index | Thread Index | Old Index