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 Disable lineout by default. ...



details:   https://anonhg.NetBSD.org/src/rev/174c04889926
branches:  trunk
changeset: 318994:174c04889926
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri May 11 23:05:41 2018 +0000
description:
Disable lineout by default. If HP is not plugged at boot, we get an
unplug event. However, no plug event when HP is plugged at boot.

diffstat:

 sys/arch/arm/sunxi/sun50i_a64_acodec.c |  18 +++++++++++-------
 sys/arch/arm/sunxi/sun8i_codec.c       |  29 +++++++++++++++--------------
 2 files changed, 26 insertions(+), 21 deletions(-)

diffs (145 lines):

diff -r 77bc5663cfb5 -r 174c04889926 sys/arch/arm/sunxi/sun50i_a64_acodec.c
--- a/sys/arch/arm/sunxi/sun50i_a64_acodec.c    Fri May 11 22:51:33 2018 +0000
+++ b/sys/arch/arm/sunxi/sun50i_a64_acodec.c    Fri May 11 23:05:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i_a64_acodec.c,v 1.3 2018/05/11 22:51:12 jmcneill Exp $ */
+/* $NetBSD: sun50i_a64_acodec.c,v 1.4 2018/05/11 23:05:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sun50i_a64_acodec.c,v 1.3 2018/05/11 22:51:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun50i_a64_acodec.c,v 1.4 2018/05/11 23:05:41 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -439,15 +439,21 @@
 {
        struct a64_acodec_softc * const sc = audio_dai_private(dai);
        const uint32_t lineout_mask = A64_LINEOUT_LEFT_EN | A64_LINEOUT_RIGHT_EN;
+       const uint32_t hppa_mask = A64_HPPA_EN;
 
        switch (jack) {
        case AUDIO_DAI_JACK_HP:
-               if (present)
+               if (present) {
                        a64_acodec_pr_set_clear(sc, A64_LINEOUT_CTRL0,
                            0, lineout_mask);
-               else
+                       a64_acodec_pr_set_clear(sc, A64_HP_CTRL,
+                           hppa_mask, 0);
+               } else {
                        a64_acodec_pr_set_clear(sc, A64_LINEOUT_CTRL0,
                            lineout_mask, 0);
+                       a64_acodec_pr_set_clear(sc, A64_HP_CTRL,
+                           0, hppa_mask);
+               }
                break;
        case AUDIO_DAI_JACK_MIC:
                /* XXX TODO */
@@ -495,12 +501,10 @@
        aprint_naive("\n");
        aprint_normal(": A64 Audio Codec (analog part)\n");
 
-       /* Right & Left LINEOUT enable */
-       a64_acodec_pr_set_clear(sc, A64_LINEOUT_CTRL0,
-           A64_LINEOUT_LEFT_EN | A64_LINEOUT_RIGHT_EN, 0);
        /* Right & Left Headphone PA enable */
        a64_acodec_pr_set_clear(sc, A64_HP_CTRL,
            A64_HPPA_EN, 0);
+
        /* Jack detect enable */
        a64_acodec_pr_set_clear(sc, A64_JACK_MIC_CTRL,
            A64_JACKDETEN | A64_INNERRESEN | A64_AUTOPLEN, 0);
diff -r 77bc5663cfb5 -r 174c04889926 sys/arch/arm/sunxi/sun8i_codec.c
--- a/sys/arch/arm/sunxi/sun8i_codec.c  Fri May 11 22:51:33 2018 +0000
+++ b/sys/arch/arm/sunxi/sun8i_codec.c  Fri May 11 23:05:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_codec.c,v 1.2 2018/05/11 22:51:12 jmcneill Exp $ */
+/* $NetBSD: sun8i_codec.c,v 1.3 2018/05/11 23:05:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.2 2018/05/11 22:51:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sun8i_codec.c,v 1.3 2018/05/11 23:05:41 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -118,7 +118,6 @@
 
        struct audio_dai_device sc_dai;
        audio_dai_tag_t         sc_codec_analog;
-       uint32_t                sc_jackdet;
        int                     sc_jackdet_pol;
 
        struct fdtbus_gpio_pin  *sc_pin_pa;
@@ -260,15 +259,15 @@
 static int
 sun8i_codec_intr(void *priv)
 {
-       struct sun8i_codec_softc * const sc = priv;
        const uint32_t mask =
            HMIC_STS_JACK_DET_OIRQ |
            HMIC_STS_JACK_DET_IIRQ |
            HMIC_STS_MIC_DET_ST;
+       struct sun8i_codec_softc * const sc = priv;
+       uint32_t val;
 
-       sc->sc_jackdet = RD4(sc, HMIC_STS);
-
-       if (sc->sc_jackdet & mask) {
+       val = RD4(sc, HMIC_STS);
+       if (val & mask) {
                /* Disable jack detect IRQ until work is complete */
                sun8i_codec_set_jackdet(sc, false);
 
@@ -276,8 +275,6 @@
                workqueue_enqueue(sc->sc_workq, &sc->sc_work, NULL);
        }
 
-       WR4(sc, HMIC_STS, sc->sc_jackdet);
-
        return 1;
 }
 
@@ -286,17 +283,19 @@
 sun8i_codec_thread(struct work *wk, void *priv)
 {
        struct sun8i_codec_softc * const sc = priv;
-       const uint32_t sts = sc->sc_jackdet;
        int hpdet = -1, micdet = -1;
+       uint32_t val;
+
+       val = RD4(sc, HMIC_STS);
 
        if (sc->sc_codec_analog) {
-               if (sts & HMIC_STS_JACK_DET_OIRQ)
+               if (val & HMIC_STS_JACK_DET_OIRQ)
                        hpdet = 0 ^ sc->sc_jackdet_pol;
-               else if (sts & HMIC_STS_JACK_DET_IIRQ)
+               else if (val & HMIC_STS_JACK_DET_IIRQ)
                        hpdet = 1 ^ sc->sc_jackdet_pol;
 
-               if (sts & HMIC_STS_MIC_DET_ST)
-                       micdet = !!(sts & HMIC_STS_MIC_PRESENT);
+               if (val & HMIC_STS_MIC_DET_ST)
+                       micdet = !!(val & HMIC_STS_MIC_PRESENT);
 
                if (hpdet != -1) {
                        audio_dai_jack_detect(sc->sc_codec_analog,
@@ -308,6 +307,8 @@
                }
        }
 
+       WR4(sc, HMIC_STS, val);
+
        /* Re-enable jack detect IRQ */
        sun8i_codec_set_jackdet(sc, true);
 }



Home | Main Index | Thread Index | Old Index