Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci/hdaudio Add AC3 passthru support, currently unte...



details:   https://anonhg.NetBSD.org/src/rev/f73a96aadb56
branches:  trunk
changeset: 769296:f73a96aadb56
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Sep 06 01:51:44 2011 +0000

description:
Add AC3 passthru support, currently untested.

diffstat:

 sys/dev/pci/hdaudio/hdafg.c      |  61 ++++++++++++++++++++++++++++-----------
 sys/dev/pci/hdaudio/hdaudioreg.h |   5 ++-
 2 files changed, 47 insertions(+), 19 deletions(-)

diffs (132 lines):

diff -r 6efb7d2fdd04 -r f73a96aadb56 sys/dev/pci/hdaudio/hdafg.c
--- a/sys/dev/pci/hdaudio/hdafg.c       Tue Sep 06 01:19:34 2011 +0000
+++ b/sys/dev/pci/hdaudio/hdafg.c       Tue Sep 06 01:51:44 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdafg.c,v 1.2 2011/02/12 15:15:34 jmcneill Exp $ */
+/* $NetBSD: hdafg.c,v 1.3 2011/09/06 01:51:44 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.2 2011/02/12 15:15:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.3 2011/09/06 01:51:44 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -3041,7 +3041,7 @@
 
        KASSERT(mode == AUMODE_PLAY || mode == AUMODE_RECORD);
 
-       dfmt = COP_DIGITAL_CONVCTRL1_DIGEN;     /* TODO: AC3 */
+       dfmt = COP_DIGITAL_CONVCTRL1_DIGEN;
 
        if (mode == AUMODE_PLAY)
                fmt = hdaudio_stream_param(sc->sc_audiodev.ad_playback,
@@ -3216,7 +3216,7 @@
 
 static bool
 hdafg_probe_encoding(struct hdafg_softc *sc,
-    u_int validbits, u_int precision, bool force)
+    u_int validbits, u_int precision, int encoding, bool force)
 {
        struct audio_format f;
        int i;
@@ -3227,7 +3227,7 @@
        memset(&f, 0, sizeof(f));
        f.driver_data = NULL;
        f.mode = 0;
-       f.encoding = AUDIO_ENCODING_SLINEAR_LE;
+       f.encoding = encoding;
        f.validbits = validbits;
        f.precision = precision;
        f.channels = 0;
@@ -3271,8 +3271,10 @@
 hdafg_configure_encodings(struct hdafg_softc *sc)
 {
        struct hdaudio_assoc *as = sc->sc_assocs;
+       struct hdaudio_widget *w;
        struct audio_format f;
-       int nchan, i;
+       uint32_t stream_format;
+       int nchan, i, nid;
 
        sc->sc_pchan = sc->sc_rchan = 0;
 
@@ -3295,20 +3297,43 @@
                    hdafg_possible_rates[i]))
                        hda_print1(sc, " %uHz", hdafg_possible_rates[i]);
 
-       if (hdafg_probe_encoding(sc, 8, 16, false))
-               hda_print1(sc, " 8/16");
-       if (hdafg_probe_encoding(sc, 16, 16, false))
-               hda_print1(sc, " 16/16");
-       if (hdafg_probe_encoding(sc, 20, 32, false))
-               hda_print1(sc, " 20/32");
-       if (hdafg_probe_encoding(sc, 24, 32, false))
-               hda_print1(sc, " 24/32");
-       if (hdafg_probe_encoding(sc, 32, 32, false))
-               hda_print1(sc, " 32/32");
+       stream_format = sc->sc_p.stream_format;
+       for (nid = sc->sc_startnode; nid < sc->sc_endnode; nid++) {
+               w = hdafg_widget_lookup(sc, nid);
+               if (w == NULL)
+                       continue;
+               stream_format |= w->w_p.stream_format;
+       }
+       if (stream_format == 0) {
+               hda_print(sc,
+                   "WARNING: unsupported stream format mask 0x%X, assuming PCM\n",
+                   stream_format);
+               stream_format |= COP_STREAM_FORMAT_PCM;
+       }
+
+       if (stream_format & COP_STREAM_FORMAT_PCM) {
+               int e = AUDIO_ENCODING_SLINEAR_LE;
+               if (hdafg_probe_encoding(sc, 8, 16, e, false))
+                       hda_print1(sc, " PCM8");
+               if (hdafg_probe_encoding(sc, 16, 16, e, false))
+                       hda_print1(sc, " PCM16");
+               if (hdafg_probe_encoding(sc, 20, 32, e, false))
+                       hda_print1(sc, " PCM20");
+               if (hdafg_probe_encoding(sc, 24, 32, e, false))
+                       hda_print1(sc, " PCM24");
+               if (hdafg_probe_encoding(sc, 32, 32, e, false))
+                       hda_print1(sc, " PCM32");
+       }
+
+       if (stream_format & COP_STREAM_FORMAT_AC3) {
+               int e = AUDIO_ENCODING_AC3;
+               if (hdafg_probe_encoding(sc, 16, 16, e, false))
+                       hda_print1(sc, " AC3");
+       }
 
        if (sc->sc_audiodev.ad_nformats == 0) {
-               hdafg_probe_encoding(sc, 16, 16, true);
-               hda_print1(sc, " 16/16*");
+               hdafg_probe_encoding(sc, 16, 16, AUDIO_ENCODING_SLINEAR_LE, true);
+               hda_print1(sc, " PCM16*");
        }
 
        /*
diff -r 6efb7d2fdd04 -r f73a96aadb56 sys/dev/pci/hdaudio/hdaudioreg.h
--- a/sys/dev/pci/hdaudio/hdaudioreg.h  Tue Sep 06 01:19:34 2011 +0000
+++ b/sys/dev/pci/hdaudio/hdaudioreg.h  Tue Sep 06 01:51:44 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudioreg.h,v 1.5 2011/02/12 15:15:34 jmcneill Exp $ */
+/* $NetBSD: hdaudioreg.h,v 1.6 2011/09/06 01:51:44 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -183,6 +183,9 @@
 #define           COP_AWCAP_TYPE_VENDOR_DEFINED           0xf
 #define         COP_SUPPORTED_PCM_SIZE_RATES            0x0a
 #define         COP_SUPPORTED_STREAM_FORMATS            0x0b
+#define          COP_STREAM_FORMAT_PCM                   (1 << 0)
+#define          COP_STREAM_FORMAT_FLOAT32               (1 << 1)
+#define          COP_STREAM_FORMAT_AC3                   (1 << 2)
 #define         COP_PIN_CAPABILITIES                    0x0c
 #define          COP_PINCAP_IMPEDANCE_SENSE_CAPABLE      (1 << 0)
 #define          COP_PINCAP_TRIGGER_REQD                 (1 << 1)



Home | Main Index | Thread Index | Old Index