CVS commit: [netbsd-8] src/sys/dev/hdaudio
Module Name:src Committed By: martin Date: Tue Oct 9 10:09:52 UTC 2018 Modified Files: src/sys/dev/hdaudio [netbsd-8]: hdafg.c Log Message: Pull up following revision(s) (requested by manu in ticket #1053): sys/dev/hdaudio/hdafg.c: revision 1.16 Fix hdaudio device configuration When disabling unassociated devices, we have a special handling for pins of type COP_AWCAP_TYPE_PIN_COMPLEX, but it came after code that may disable any pins, including the ones that should be handled as COP_AWCAP_TYPE_PIN_COMPLEX. The result was that hdaudio could fail to detect some devices. We fix the situation by making sure that COP_AWCAP_TYPE_PIN_COMPLEX pins always get their specific handling. The change makes the built-in speaker work on Dell OptiPlex 5060 To generate a diff of this commit: cvs rdiff -u -r1.12.2.1 -r1.12.2.2 src/sys/dev/hdaudio/hdafg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hdaudio/hdafg.c diff -u src/sys/dev/hdaudio/hdafg.c:1.12.2.1 src/sys/dev/hdaudio/hdafg.c:1.12.2.2 --- src/sys/dev/hdaudio/hdafg.c:1.12.2.1 Sun Aug 20 04:50:38 2017 +++ src/sys/dev/hdaudio/hdafg.c Tue Oct 9 10:09:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hdafg.c,v 1.12.2.1 2017/08/20 04:50:38 snj Exp $ */ +/* $NetBSD: hdafg.c,v 1.12.2.2 2018/10/09 10:09:51 martin Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.12.2.1 2017/08/20 04:50:38 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.12.2.2 2018/10/09 10:09:51 martin Exp $"); #include #include @@ -2106,25 +2106,25 @@ hdafg_disable_unassoc(struct hdafg_softc struct hdaudio_control *ctl; int i, j, k; - /* Disable unassociated widgets */ for (i = sc->sc_startnode; i < sc->sc_endnode; i++) { w = hdafg_widget_lookup(sc, i); if (w == NULL || w->w_enable == false) continue; - if (w->w_bindas == -1) { - w->w_enable = 0; - hda_trace(sc, "disable %02X [unassociated]\n", - w->w_nid); + + /* Disable unassociated widgets */ + if (w->w_type != COP_AWCAP_TYPE_PIN_COMPLEX) { + if (w->w_bindas == -1) { +w->w_enable = 0; +hda_trace(sc, "disable %02X [unassociated]\n", +w->w_nid); + } + continue; } - } - /* Disable input connections on input pin and output on output */ - for (i = sc->sc_startnode; i < sc->sc_endnode; i++) { - w = hdafg_widget_lookup(sc, i); - if (w == NULL || w->w_enable == false) - continue; - if (w->w_type != COP_AWCAP_TYPE_PIN_COMPLEX) - continue; + /* + * Disable input connections on input pin + * and output on output pin + */ if (w->w_bindas < 0) continue; if (as[w->w_bindas].as_dir == HDAUDIO_PINDIR_IN) {
CVS commit: [netbsd-8] src/sys/dev/hdaudio
Module Name:src Committed By: martin Date: Mon Nov 27 10:21:26 UTC 2017 Modified Files: src/sys/dev/hdaudio [netbsd-8]: hdaudio.c Log Message: Pull up following revision(s) (requested by jmcneill in ticket #391): sys/dev/hdaudio/hdaudio.c: revision 1.7 sys/dev/hdaudio/hdaudio.c: revision 1.8 Always access CORBCTL using hda_read1/hda_write1 (it is an 8-bit wide reg). Reported by Michal Necasek. Always go through RIRB startup process, initialize RIRB interrupt count register, and ack RIRBs as we process them in polling mode. XXX pullup To generate a diff of this commit: cvs rdiff -u -r1.4.10.2 -r1.4.10.3 src/sys/dev/hdaudio/hdaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hdaudio/hdaudio.c diff -u src/sys/dev/hdaudio/hdaudio.c:1.4.10.2 src/sys/dev/hdaudio/hdaudio.c:1.4.10.3 --- src/sys/dev/hdaudio/hdaudio.c:1.4.10.2 Fri Nov 24 08:35:34 2017 +++ src/sys/dev/hdaudio/hdaudio.c Mon Nov 27 10:21:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: hdaudio.c,v 1.4.10.2 2017/11/24 08:35:34 martin Exp $ */ +/* $NetBSD: hdaudio.c,v 1.4.10.3 2017/11/27 10:21:26 martin Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd@@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.4.10.2 2017/11/24 08:35:34 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.4.10.3 2017/11/27 10:21:26 martin Exp $"); #include #include @@ -347,6 +347,9 @@ hdaudio_command_unlocked(struct hdaudio_ hdaudio_corb_enqueue(sc, co->co_addr, nid, control, param); result = hdaudio_rirb_dequeue(sc, false); + /* Clear response interrupt status */ + hda_write1(sc, HDAUDIO_MMIO_RIRBSTS, hda_read1(sc, HDAUDIO_MMIO_RIRBSTS)); + return result; } @@ -428,10 +431,10 @@ hdaudio_corb_stop(struct hdaudio_softc * corbctl = hda_read1(sc, HDAUDIO_MMIO_CORBCTL); if (corbctl & HDAUDIO_CORBCTL_RUN) { corbctl &= ~HDAUDIO_CORBCTL_RUN; - hda_write4(sc, HDAUDIO_MMIO_CORBCTL, corbctl); + hda_write1(sc, HDAUDIO_MMIO_CORBCTL, corbctl); do { hda_delay(10); - corbctl = hda_read4(sc, HDAUDIO_MMIO_CORBCTL); + corbctl = hda_read1(sc, HDAUDIO_MMIO_CORBCTL); } while (--retry > 0 && (corbctl & HDAUDIO_CORBCTL_RUN) != 0); if (retry == 0) { hda_error(sc, "timeout stopping CORB\n"); @@ -452,10 +455,10 @@ hdaudio_corb_start(struct hdaudio_softc corbctl = hda_read1(sc, HDAUDIO_MMIO_CORBCTL); if ((corbctl & HDAUDIO_CORBCTL_RUN) == 0) { corbctl |= HDAUDIO_CORBCTL_RUN; - hda_write4(sc, HDAUDIO_MMIO_CORBCTL, corbctl); + hda_write1(sc, HDAUDIO_MMIO_CORBCTL, corbctl); do { hda_delay(10); - corbctl = hda_read4(sc, HDAUDIO_MMIO_CORBCTL); + corbctl = hda_read1(sc, HDAUDIO_MMIO_CORBCTL); } while (--retry > 0 && (corbctl & HDAUDIO_CORBCTL_RUN) == 0); if (retry == 0) { hda_error(sc, "timeout starting CORB\n"); @@ -497,20 +500,21 @@ hdaudio_rirb_start(struct hdaudio_softc uint8_t rirbctl; int retry = HDAUDIO_RIRB_TIMEOUT; - /* Start the RIRB if necessary */ + /* Set the RIRB interrupt count */ + hda_write2(sc, HDAUDIO_MMIO_RINTCNT, 1); + + /* Start the RIRB */ rirbctl = hda_read1(sc, HDAUDIO_MMIO_RIRBCTL); - if ((rirbctl & (HDAUDIO_RIRBCTL_RUN|HDAUDIO_RIRBCTL_INT_EN)) == 0) { - rirbctl |= HDAUDIO_RIRBCTL_RUN; - rirbctl |= HDAUDIO_RIRBCTL_INT_EN; - hda_write1(sc, HDAUDIO_MMIO_RIRBCTL, rirbctl); - do { - hda_delay(10); - rirbctl = hda_read1(sc, HDAUDIO_MMIO_RIRBCTL); - } while (--retry > 0 && (rirbctl & HDAUDIO_RIRBCTL_RUN) == 0); - if (retry == 0) { - hda_error(sc, "timeout starting RIRB\n"); - return ETIME; - } + rirbctl |= HDAUDIO_RIRBCTL_RUN; + rirbctl |= HDAUDIO_RIRBCTL_INT_EN; + hda_write1(sc, HDAUDIO_MMIO_RIRBCTL, rirbctl); + do { + hda_delay(10); + rirbctl = hda_read1(sc, HDAUDIO_MMIO_RIRBCTL); + } while (--retry > 0 && (rirbctl & HDAUDIO_RIRBCTL_RUN) == 0); + if (retry == 0) { + hda_error(sc, "timeout starting RIRB\n"); + return ETIME; } return 0; @@ -558,8 +562,6 @@ static int hdaudio_rirb_config(struct hdaudio_softc *sc) { uint32_t rirbubase, rirblbase; - uint32_t rirbwp; - int retry = HDAUDIO_RIRB_TIMEOUT; /* Program command buffer base address and size */ rirblbase = (uint32_t)DMA_DMAADDR(>sc_rirb); @@ -570,15 +572,6 @@ hdaudio_rirb_config(struct hdaudio_softc /* Clear the write pointer */ hda_write2(sc, HDAUDIO_MMIO_RIRBWP, HDAUDIO_RIRBWP_WP_RESET); - hda_write2(sc, HDAUDIO_MMIO_RIRBWP, 0); - do { - hda_delay(10); - rirbwp = hda_read2(sc, HDAUDIO_MMIO_RIRBWP); - } while (--retry > 0 && (rirbwp & HDAUDIO_RIRBWP_WP_RESET) != 0); - if (retry == 0) { - hda_error(sc, "timeout resetting RIRB\n"); - return ETIME; - } sc->sc_rirbrp = 0; return 0;
CVS commit: [netbsd-8] src/sys/dev/hdaudio
Module Name:src Committed By: martin Date: Fri Nov 24 08:35:34 UTC 2017 Modified Files: src/sys/dev/hdaudio [netbsd-8]: hdaudio.c Log Message: Pull up following revision(s) (requested by jmcneill in ticket #388): sys/dev/hdaudio/hdaudio.c: revision 1.6 Enter link reset even if GCTL says we are already in reset state. Fixes hdaudio codec detection under VirtualBox on a "cold" boot. XXX pullup To generate a diff of this commit: cvs rdiff -u -r1.4.10.1 -r1.4.10.2 src/sys/dev/hdaudio/hdaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hdaudio/hdaudio.c diff -u src/sys/dev/hdaudio/hdaudio.c:1.4.10.1 src/sys/dev/hdaudio/hdaudio.c:1.4.10.2 --- src/sys/dev/hdaudio/hdaudio.c:1.4.10.1 Mon Jun 5 08:13:05 2017 +++ src/sys/dev/hdaudio/hdaudio.c Fri Nov 24 08:35:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: hdaudio.c,v 1.4.10.1 2017/06/05 08:13:05 snj Exp $ */ +/* $NetBSD: hdaudio.c,v 1.4.10.2 2017/11/24 08:35:34 martin Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd@@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.4.10.1 2017/06/05 08:13:05 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.4.10.2 2017/11/24 08:35:34 martin Exp $"); #include #include @@ -612,21 +612,21 @@ hdaudio_reset(struct hdaudio_softc *sc) hda_write1(sc, HDAUDIO_MMIO_RIRBSTS, hda_read1(sc, HDAUDIO_MMIO_RIRBSTS)); - /* If the controller isn't in reset state, initiate the transition */ + /* Put the controller into reset state */ gctl = hda_read4(sc, HDAUDIO_MMIO_GCTL); - if (gctl & HDAUDIO_GCTL_CRST) { - gctl &= ~HDAUDIO_GCTL_CRST; - hda_write4(sc, HDAUDIO_MMIO_GCTL, gctl); - do { - hda_delay(10); - gctl = hda_read4(sc, HDAUDIO_MMIO_GCTL); - } while (--retry > 0 && (gctl & HDAUDIO_GCTL_CRST) != 0); - if (retry == 0) { - hda_error(sc, "timeout entering reset state\n"); - return ETIME; - } + gctl &= ~HDAUDIO_GCTL_CRST; + hda_write4(sc, HDAUDIO_MMIO_GCTL, gctl); + do { + hda_delay(10); + gctl = hda_read4(sc, HDAUDIO_MMIO_GCTL); + } while (--retry > 0 && (gctl & HDAUDIO_GCTL_CRST) != 0); + if (retry == 0) { + hda_error(sc, "timeout entering reset state\n"); + return ETIME; } + hda_delay(1000); + /* Now the controller is in reset state, so bring it out */ retry = HDAUDIO_RESET_TIMEOUT; hda_write4(sc, HDAUDIO_MMIO_GCTL, gctl | HDAUDIO_GCTL_CRST); @@ -639,6 +639,8 @@ hdaudio_reset(struct hdaudio_softc *sc) return ETIME; } + hda_delay(2000); + /* Accept unsolicited responses */ hda_write4(sc, HDAUDIO_MMIO_GCTL, gctl | HDAUDIO_GCTL_UNSOL_EN);
CVS commit: [netbsd-8] src/sys/dev/hdaudio
Module Name:src Committed By: snj Date: Sun Aug 20 04:50:38 UTC 2017 Modified Files: src/sys/dev/hdaudio [netbsd-8]: hdafg.c hdafg_dd.c Log Message: Pull up following revision(s) (requested by mrg in ticket #210): sys/dev/hdaudio/hdafg.c: revision 1.13 sys/dev/hdaudio/hdafg_dd.c: revision 1.2 put all the ELD debugging messages under #ifdef HDAFG_HDMI_DEBUG. this silences a frequent and largely useless series of messages in my dmesg. ok jmcneill. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.12.2.1 src/sys/dev/hdaudio/hdafg.c cvs rdiff -u -r1.1 -r1.1.12.1 src/sys/dev/hdaudio/hdafg_dd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hdaudio/hdafg.c diff -u src/sys/dev/hdaudio/hdafg.c:1.12 src/sys/dev/hdaudio/hdafg.c:1.12.2.1 --- src/sys/dev/hdaudio/hdafg.c:1.12 Thu Jun 1 02:45:10 2017 +++ src/sys/dev/hdaudio/hdafg.c Sun Aug 20 04:50:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: hdafg.c,v 1.12 2017/06/01 02:45:10 chs Exp $ */ +/* $NetBSD: hdafg.c,v 1.12.2.1 2017/08/20 04:50:38 snj Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd@@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.12 2017/06/01 02:45:10 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.12.2.1 2017/08/20 04:50:38 snj Exp $"); #include #include @@ -879,15 +879,19 @@ hdafg_assoc_dump_dd(struct hdafg_softc * res = (*cmd)(sc->sc_codec, as->as_pins[pin], CORB_GET_HDMI_ELD_DATA, i); if (!(res & COP_ELD_VALID)) { +#ifdef HDAFG_HDMI_DEBUG hda_error(sc, "bad ELD size (%u/%u)\n", i, elddatalen); +#endif break; } elddata[i] = COP_ELD_DATA(res); } if (hdafg_dd_parse_info(elddata, elddatalen, ) != 0) { +#ifdef HDAFG_HDMI_DEBUG hda_error(sc, "failed to parse ELD data\n"); +#endif return; } @@ -4342,7 +4346,9 @@ hdafg_unsol(device_t self, uint8_t tag) switch (tag) { case HDAUDIO_UNSOLTAG_EVENT_DD: +#ifdef HDAFG_HDMI_DEBUG hda_print(sc, "unsol: display device hotplug\n"); +#endif for (i = 0; i < sc->sc_nassocs; i++) { if (as[i].as_displaydev == false) continue; @@ -4354,7 +4360,9 @@ hdafg_unsol(device_t self, uint8_t tag) } break; default: +#ifdef HDAFG_HDMI_DEBUG hda_print(sc, "unsol: tag=%u\n", tag); +#endif break; } Index: src/sys/dev/hdaudio/hdafg_dd.c diff -u src/sys/dev/hdaudio/hdafg_dd.c:1.1 src/sys/dev/hdaudio/hdafg_dd.c:1.1.12.1 --- src/sys/dev/hdaudio/hdafg_dd.c:1.1 Sat Mar 28 14:09:59 2015 +++ src/sys/dev/hdaudio/hdafg_dd.c Sun Aug 20 04:50:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: hdafg_dd.c,v 1.1 2015/03/28 14:09:59 jmcneill Exp $ */ +/* $NetBSD: hdafg_dd.c,v 1.1.12.1 2017/08/20 04:50:38 snj Exp $ */ /* * Copyright (c) 2011 Jared D. McNeill @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hdafg_dd.c,v 1.1 2015/03/28 14:09:59 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdafg_dd.c,v 1.1.12.1 2017/08/20 04:50:38 snj Exp $"); #include #include @@ -50,12 +50,16 @@ hdafg_dd_parse_info(uint8_t *data, size_ struct eld_baseline_block *block = >eld; unsigned int i; +#ifdef HDAFG_HDMI_DEBUG printf("hdafg_dd_parse_info: datalen=%u\n", (unsigned int)datalen); +#endif memset(hdi, 0, sizeof(*hdi)); if (datalen < sizeof(block->header)) { +#ifdef HDAFG_HDMI_DEBUG printf(" no room for header\n"); +#endif return EINVAL; } @@ -65,7 +69,9 @@ hdafg_dd_parse_info(uint8_t *data, size_ if (datalen < block->header.baseline_eld_len * 4 || datalen < sizeof(*block) - sizeof(block->header)) { +#ifdef HDAFG_HDMI_DEBUG printf(" ack!\n"); +#endif return EINVAL; } @@ -76,7 +82,9 @@ hdafg_dd_parse_info(uint8_t *data, size_ datalen -= sizeof(*block) - sizeof(block->header); if (datalen < ELD_MNL(block)) { +#ifdef HDAFG_HDMI_DEBUG printf(" MNL=%u\n", ELD_MNL(block)); +#endif return EINVAL; } @@ -85,10 +93,12 @@ hdafg_dd_parse_info(uint8_t *data, size_ datalen -= ELD_MNL(block); if (datalen != ELD_SAD_COUNT(block) * sizeof(hdi->sad[0])) { +#ifdef HDAFG_HDMI_DEBUG printf(" datalen %u sadcount %u sizeof sad %u\n", (unsigned int)datalen, ELD_SAD_COUNT(block), (unsigned int)sizeof(hdi->sad[0])); +#endif return EINVAL; } hdi->nsad = ELD_SAD_COUNT(block); @@ -98,7 +108,9 @@ hdafg_dd_parse_info(uint8_t *data, size_ datalen -= sizeof(hdi->sad[i]); } +#ifdef HDAFG_HDMI_DEBUG printf("datalen = %u\n", (unsigned int)datalen); +#endif KASSERT(datalen == 0); return 0;