Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/dev/hdaudio/hdaudio.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/dev/hdaudio/hdaudio.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.8 retrieving revision 1.8.6.1 diff -u -p -r1.8 -r1.8.6.1 --- src/sys/dev/hdaudio/hdaudio.c 2017/11/24 17:51:10 1.8 +++ src/sys/dev/hdaudio/hdaudio.c 2020/04/08 14:08:05 1.8.6.1 @@ -1,4 +1,4 @@ -/* $NetBSD: hdaudio.c,v 1.8 2017/11/24 17:51:10 jmcneill Exp $ */ +/* $NetBSD: hdaudio.c,v 1.8.6.1 2020/04/08 14:08:05 martin Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.8 2017/11/24 17:51:10 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.8.6.1 2020/04/08 14:08:05 martin Exp $"); #include #include @@ -121,36 +121,21 @@ hdaudio_codec_init(struct hdaudio_softc static void hdaudio_init(struct hdaudio_softc *sc) { - uint16_t gcap; - int nos, nis, nbidir; -#if defined(HDAUDIO_DEBUG) - uint8_t vmin, vmaj; - int nsdo, addr64; -#endif - -#if defined(HDAUDIO_DEBUG) - vmaj = hda_read1(sc, HDAUDIO_MMIO_VMAJ); - vmin = hda_read1(sc, HDAUDIO_MMIO_VMIN); - - hda_print(sc, "High Definition Audio version %d.%d\n", vmaj, vmin); -#endif + const uint8_t vmaj = hda_read1(sc, HDAUDIO_MMIO_VMAJ); + const uint8_t vmin = hda_read1(sc, HDAUDIO_MMIO_VMIN); + const uint16_t gcap = hda_read2(sc, HDAUDIO_MMIO_GCAP); + const int nis = HDAUDIO_GCAP_ISS(gcap); + const int nos = HDAUDIO_GCAP_OSS(gcap); + const int nbidir = HDAUDIO_GCAP_BSS(gcap); + const int nsdo = HDAUDIO_GCAP_NSDO(gcap); + const int addr64 = HDAUDIO_GCAP_64OK(gcap); - gcap = hda_read2(sc, HDAUDIO_MMIO_GCAP); - nis = HDAUDIO_GCAP_ISS(gcap); - nos = HDAUDIO_GCAP_OSS(gcap); - nbidir = HDAUDIO_GCAP_BSS(gcap); + hda_print(sc, "HDA ver. %d.%d, OSS %d, ISS %d, BSS %d, SDO %d%s\n", + vmaj, vmin, nos, nis, nbidir, nsdo, addr64 ? ", 64-bit" : ""); /* Initialize codecs and streams */ hdaudio_codec_init(sc); hdaudio_stream_init(sc, nis, nos, nbidir); - -#if defined(HDAUDIO_DEBUG) - nsdo = HDAUDIO_GCAP_NSDO(gcap); - addr64 = HDAUDIO_GCAP_64OK(gcap); - - hda_print(sc, "OSS %d ISS %d BSS %d SDO %d%s\n", - nos, nis, nbidir, nsdo, addr64 ? " 64-bit" : ""); -#endif } static int @@ -795,8 +780,6 @@ hdaudio_attach(device_t dev, struct hdau mutex_init(&sc->sc_corb_mtx, MUTEX_DEFAULT, IPL_AUDIO); mutex_init(&sc->sc_stream_mtx, MUTEX_DEFAULT, IPL_AUDIO); - hdaudio_init(sc); - /* * Put the controller into a known state by entering and leaving * CRST as necessary. @@ -814,6 +797,15 @@ hdaudio_attach(device_t dev, struct hdau * In reality, we need to wait longer than this. */ hda_delay(HDAUDIO_CODEC_DELAY); + + /* + * Read device capabilities + */ + hdaudio_init(sc); + + /* + * Detect codecs + */ if (hdaudio_codec_probe(sc) == 0) { hda_error(sc, "no codecs found\n"); err = ENODEV;