--- sys/dev/sound/pci/hda/hdac.c.orig Tue Jun 26 14:14:28 2007 +++ sys/dev/sound/pci/hda/hdac.c Wed Jun 27 15:25:42 2007 @@ -5866,15 +5866,14 @@ return (err); } -#ifdef SND_DEBUG static int -sysctl_hdac_dump(SYSCTL_HANDLER_ARGS) +sysctl_hdac_pindump(SYSCTL_HANDLER_ARGS) { struct hdac_softc *sc; struct hdac_devinfo *devinfo; struct hdac_widget *w; device_t dev; - uint32_t res, execres; + uint32_t res, pincap, timeout; int i, err, val; nid_t cad; @@ -5896,11 +5895,27 @@ if (w == NULL || w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) continue; - execres = hdac_command(sc, HDA_CMD_SET_PIN_SENSE(cad, w->nid, 0), - cad); - res = hdac_command(sc, HDA_CMD_GET_PIN_SENSE(cad, w->nid), cad); - device_printf(dev, "nid=%-3d exec=0x%08x sense=0x%08x [%s]\n", - w->nid, execres, res, + pincap = w->wclass.pin.cap; + if ((HDA_PARAM_PIN_CAP_IMP_SENSE_CAP(pincap) || + HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(pincap)) && + HDA_PARAM_PIN_CAP_TRIGGER_REQD(pincap)) { + timeout = 10000; + hdac_command(sc, + HDA_CMD_SET_PIN_SENSE(cad, w->nid, 0), cad); + do { + DELAY(10); + res = hdac_command(sc, + HDA_CMD_GET_PIN_SENSE(cad, w->nid), cad); + } while ((res & 0x7fffffff) == 0x7fffffff && + --timeout != 0); + } else { + timeout = -1; + res = hdac_command(sc, HDA_CMD_GET_PIN_SENSE(cad, + w->nid), cad); + } + device_printf(dev, + "PIN_SENSE: nid=%-3d timeout=%d res=0x%08x [%s]\n", + w->nid, timeout, res, (w->enable == 0) ? "DISABLED" : "ENABLED"); } device_printf(dev, @@ -5910,7 +5925,7 @@ HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->function.audio.gpio), HDA_PARAM_GPIO_COUNT_GPI_WAKE(devinfo->function.audio.gpio), HDA_PARAM_GPIO_COUNT_GPI_UNSOL(devinfo->function.audio.gpio)); - if (1 || HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->function.audio.gpio) > 0) { + if (HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->function.audio.gpio) > 0) { device_printf(dev, " GPI:"); res = hdac_command(sc, HDA_CMD_GET_GPI_DATA(cad, devinfo->nid), cad); @@ -5927,13 +5942,13 @@ HDA_CMD_GET_GPI_STICKY_MASK(cad, devinfo->nid), cad); printf(" sticky=0x%08x\n", res); } - if (1 || HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->function.audio.gpio) > 0) { + if (HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->function.audio.gpio) > 0) { device_printf(dev, " GPO:"); res = hdac_command(sc, HDA_CMD_GET_GPO_DATA(cad, devinfo->nid), cad); printf(" data=0x%08x\n", res); } - if (1 || HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->function.audio.gpio) > 0) { + if (HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->function.audio.gpio) > 0) { device_printf(dev, "GPI0:"); res = hdac_command(sc, HDA_CMD_GET_GPIO_DATA(cad, devinfo->nid), cad); @@ -5959,7 +5974,6 @@ return (0); } #endif -#endif static void hdac_attach2(void *arg) @@ -6170,12 +6184,10 @@ "polling_interval", CTLTYPE_INT | CTLFLAG_RW, sc->dev, sizeof(sc->dev), sysctl_hdac_polling_interval, "I", "Controller/Jack Sense polling interval (1-1000 ms)"); -#ifdef SND_DEBUG SYSCTL_ADD_PROC(device_get_sysctl_ctx(sc->dev), SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, - "dump", CTLTYPE_INT | CTLFLAG_RW, sc->dev, sizeof(sc->dev), - sysctl_hdac_dump, "I", "Dump states"); -#endif + "pindump", CTLTYPE_INT | CTLFLAG_RW, sc->dev, sizeof(sc->dev), + sysctl_hdac_pindump, "I", "Dump pin states/data"); #endif snprintf(status, SND_STATUSLEN, "at memory 0x%lx irq %ld %s [%s]",