Deleted Added
full compact
hdac.c (183025) hdac.c (183097)
1/*-
2 * Copyright (c) 2006 Stephane E. Potvin <sepotvin@videotron.ca>
3 * Copyright (c) 2006 Ariff Abdullah <ariff@FreeBSD.org>
4 * Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 69 unchanged lines hidden (view full) ---

78
79#include <dev/sound/pci/hda/hdac_private.h>
80#include <dev/sound/pci/hda/hdac_reg.h>
81#include <dev/sound/pci/hda/hda_reg.h>
82#include <dev/sound/pci/hda/hdac.h>
83
84#include "mixer_if.h"
85
1/*-
2 * Copyright (c) 2006 Stephane E. Potvin <sepotvin@videotron.ca>
3 * Copyright (c) 2006 Ariff Abdullah <ariff@FreeBSD.org>
4 * Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 69 unchanged lines hidden (view full) ---

78
79#include <dev/sound/pci/hda/hdac_private.h>
80#include <dev/sound/pci/hda/hdac_reg.h>
81#include <dev/sound/pci/hda/hda_reg.h>
82#include <dev/sound/pci/hda/hdac.h>
83
84#include "mixer_if.h"
85
86#define HDA_DRV_TEST_REV "20080913_0111"
87#define HDA_WIDGET_PARSER_REV 2
86#define HDA_DRV_TEST_REV "20080916_0112"
88
87
89SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pci/hda/hdac.c 183025 2008-09-14 17:40:53Z mav $");
88SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pci/hda/hdac.c 183097 2008-09-16 20:03:34Z mav $");
90
91#define HDA_BOOTVERBOSE(stmt) do { \
92 if (bootverbose != 0 || snd_verbose > 3) { \
93 stmt \
94 } \
95} while(0)
96
89
90#define HDA_BOOTVERBOSE(stmt) do { \
91 if (bootverbose != 0 || snd_verbose > 3) { \
92 stmt \
93 } \
94} while(0)
95
96#define HDA_BOOTHVERBOSE(stmt) do { \
97 if (snd_verbose > 3) { \
98 stmt \
99 } \
100} while(0)
101
97#if 1
98#undef HDAC_INTR_EXTRA
99#define HDAC_INTR_EXTRA 1
100#endif
101
102#define hdac_lock(sc) snd_mtxlock((sc)->lock)
103#define hdac_unlock(sc) snd_mtxunlock((sc)->lock)
104#define hdac_lockassert(sc) snd_mtxassert((sc)->lock)

--- 1207 unchanged lines hidden (view full) ---

1312 HDAC_RIRBSIZE_RIRBSZCAP_2)
1313 sc->rirb_size = 2;
1314 else {
1315 device_printf(sc->dev, "%s: Invalid rirb size (%x)\n",
1316 __func__, rirbsize);
1317 return (ENXIO);
1318 }
1319
102#if 1
103#undef HDAC_INTR_EXTRA
104#define HDAC_INTR_EXTRA 1
105#endif
106
107#define hdac_lock(sc) snd_mtxlock((sc)->lock)
108#define hdac_unlock(sc) snd_mtxunlock((sc)->lock)
109#define hdac_lockassert(sc) snd_mtxassert((sc)->lock)

--- 1207 unchanged lines hidden (view full) ---

1317 HDAC_RIRBSIZE_RIRBSZCAP_2)
1318 sc->rirb_size = 2;
1319 else {
1320 device_printf(sc->dev, "%s: Invalid rirb size (%x)\n",
1321 __func__, rirbsize);
1322 return (ENXIO);
1323 }
1324
1320 HDA_BOOTVERBOSE(
1325 HDA_BOOTHVERBOSE(
1321 device_printf(sc->dev, " CORB size: %d\n", sc->corb_size);
1322 device_printf(sc->dev, " RIRB size: %d\n", sc->rirb_size);
1323 device_printf(sc->dev, " Streams: ISS=%d OSS=%d BSS=%d\n",
1324 sc->num_iss, sc->num_oss, sc->num_bss);
1325 );
1326
1327 return (0);
1328}

--- 82 unchanged lines hidden (view full) ---

1411 if (result != 0 || dma->dma_paddr == 0) {
1412 if (result == 0)
1413 result = ENOMEM;
1414 device_printf(sc->dev, "%s: bus_dmamem_load failed (%x)\n",
1415 __func__, result);
1416 goto hdac_dma_alloc_fail;
1417 }
1418
1326 device_printf(sc->dev, " CORB size: %d\n", sc->corb_size);
1327 device_printf(sc->dev, " RIRB size: %d\n", sc->rirb_size);
1328 device_printf(sc->dev, " Streams: ISS=%d OSS=%d BSS=%d\n",
1329 sc->num_iss, sc->num_oss, sc->num_bss);
1330 );
1331
1332 return (0);
1333}

--- 82 unchanged lines hidden (view full) ---

1416 if (result != 0 || dma->dma_paddr == 0) {
1417 if (result == 0)
1418 result = ENOMEM;
1419 device_printf(sc->dev, "%s: bus_dmamem_load failed (%x)\n",
1420 __func__, result);
1421 goto hdac_dma_alloc_fail;
1422 }
1423
1419 HDA_BOOTVERBOSE(
1424 HDA_BOOTHVERBOSE(
1420 device_printf(sc->dev, "%s: size=%ju -> roundsz=%ju\n",
1421 __func__, (uintmax_t)size, (uintmax_t)roundsz);
1422 );
1423
1424 return (0);
1425
1426hdac_dma_alloc_fail:
1427 hdac_dma_free(sc, dma);

--- 376 unchanged lines hidden (view full) ---

1804 sc->pci_subvendor);
1805 );
1806 subnode = hdac_command(sc,
1807 HDA_CMD_GET_PARAMETER(cad, 0x0, HDA_PARAM_SUB_NODE_COUNT),
1808 cad);
1809 startnode = HDA_PARAM_SUB_NODE_COUNT_START(subnode);
1810 endnode = startnode + HDA_PARAM_SUB_NODE_COUNT_TOTAL(subnode);
1811
1425 device_printf(sc->dev, "%s: size=%ju -> roundsz=%ju\n",
1426 __func__, (uintmax_t)size, (uintmax_t)roundsz);
1427 );
1428
1429 return (0);
1430
1431hdac_dma_alloc_fail:
1432 hdac_dma_free(sc, dma);

--- 376 unchanged lines hidden (view full) ---

1809 sc->pci_subvendor);
1810 );
1811 subnode = hdac_command(sc,
1812 HDA_CMD_GET_PARAMETER(cad, 0x0, HDA_PARAM_SUB_NODE_COUNT),
1813 cad);
1814 startnode = HDA_PARAM_SUB_NODE_COUNT_START(subnode);
1815 endnode = startnode + HDA_PARAM_SUB_NODE_COUNT_TOTAL(subnode);
1816
1812 HDA_BOOTVERBOSE(
1817 HDA_BOOTHVERBOSE(
1813 device_printf(sc->dev, "\tstartnode=%d endnode=%d\n",
1814 startnode, endnode);
1815 );
1816
1817 codec->fgs = (struct hdac_devinfo *)malloc(sizeof(struct hdac_devinfo) *
1818 (endnode - startnode), M_HDAC, M_NOWAIT | M_ZERO);
1819 if (codec->fgs == NULL) {
1820 device_printf(sc->dev, "%s: Unable to allocate function groups\n",

--- 1326 unchanged lines hidden (view full) ---

3147{
3148 struct hdac_softc *sc = ch->devinfo->codec->sc;
3149 struct hdac_audio_as *as = &ch->devinfo->function.audio.as[ch->as];
3150 struct hdac_widget *w;
3151 int i, chn, totalchn, c;
3152 nid_t cad = ch->devinfo->codec->cad;
3153 uint16_t fmt, dfmt;
3154
1818 device_printf(sc->dev, "\tstartnode=%d endnode=%d\n",
1819 startnode, endnode);
1820 );
1821
1822 codec->fgs = (struct hdac_devinfo *)malloc(sizeof(struct hdac_devinfo) *
1823 (endnode - startnode), M_HDAC, M_NOWAIT | M_ZERO);
1824 if (codec->fgs == NULL) {
1825 device_printf(sc->dev, "%s: Unable to allocate function groups\n",

--- 1326 unchanged lines hidden (view full) ---

3152{
3153 struct hdac_softc *sc = ch->devinfo->codec->sc;
3154 struct hdac_audio_as *as = &ch->devinfo->function.audio.as[ch->as];
3155 struct hdac_widget *w;
3156 int i, chn, totalchn, c;
3157 nid_t cad = ch->devinfo->codec->cad;
3158 uint16_t fmt, dfmt;
3159
3155 HDA_BOOTVERBOSE(
3160 HDA_BOOTHVERBOSE(
3156 device_printf(ch->pdevinfo->dev,
3157 "PCMDIR_%s: Stream setup fmt=%08x speed=%d\n",
3158 (ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC",
3159 ch->fmt, ch->spd);
3160 );
3161 fmt = 0;
3162 if (ch->fmt & AFMT_S16_LE)
3163 fmt |= ch->bit16 << 4;

--- 26 unchanged lines hidden (view full) ---

3190 chn = 0;
3191 for (i = 0; ch->io[i] != -1; i++) {
3192 w = hdac_widget_get(ch->devinfo, ch->io[i]);
3193 if (w == NULL)
3194 continue;
3195
3196 if (as->hpredir >= 0 && i == as->pincnt)
3197 chn = 0;
3161 device_printf(ch->pdevinfo->dev,
3162 "PCMDIR_%s: Stream setup fmt=%08x speed=%d\n",
3163 (ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC",
3164 ch->fmt, ch->spd);
3165 );
3166 fmt = 0;
3167 if (ch->fmt & AFMT_S16_LE)
3168 fmt |= ch->bit16 << 4;

--- 26 unchanged lines hidden (view full) ---

3195 chn = 0;
3196 for (i = 0; ch->io[i] != -1; i++) {
3197 w = hdac_widget_get(ch->devinfo, ch->io[i]);
3198 if (w == NULL)
3199 continue;
3200
3201 if (as->hpredir >= 0 && i == as->pincnt)
3202 chn = 0;
3198 HDA_BOOTVERBOSE(
3203 HDA_BOOTHVERBOSE(
3199 device_printf(ch->pdevinfo->dev,
3200 "PCMDIR_%s: Stream setup nid=%d: "
3201 "fmt=0x%04x, dfmt=0x%04x\n",
3202 (ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC",
3203 ch->io[i], fmt, dfmt);
3204 );
3205 hdac_command(sc,
3206 HDA_CMD_SET_CONV_FMT(cad, ch->io[i], fmt), cad);

--- 438 unchanged lines hidden (view full) ---

3645 * according to requested sources. */
3646 muted = (src & cw->ossmask) ? 0 : 1;
3647 if (muted != ctl->forcemute) {
3648 ctl->forcemute = muted;
3649 hdac_audio_ctl_amp_set(ctl,
3650 HDA_AMP_MUTE_DEFAULT,
3651 HDA_AMP_VOL_DEFAULT, HDA_AMP_VOL_DEFAULT);
3652 }
3204 device_printf(ch->pdevinfo->dev,
3205 "PCMDIR_%s: Stream setup nid=%d: "
3206 "fmt=0x%04x, dfmt=0x%04x\n",
3207 (ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC",
3208 ch->io[i], fmt, dfmt);
3209 );
3210 hdac_command(sc,
3211 HDA_CMD_SET_CONV_FMT(cad, ch->io[i], fmt), cad);

--- 438 unchanged lines hidden (view full) ---

3650 * according to requested sources. */
3651 muted = (src & cw->ossmask) ? 0 : 1;
3652 if (muted != ctl->forcemute) {
3653 ctl->forcemute = muted;
3654 hdac_audio_ctl_amp_set(ctl,
3655 HDA_AMP_MUTE_DEFAULT,
3656 HDA_AMP_VOL_DEFAULT, HDA_AMP_VOL_DEFAULT);
3657 }
3653 HDA_BOOTVERBOSE(
3658 HDA_BOOTHVERBOSE(
3654 device_printf(pdevinfo->dev,
3655 "Recsel (%s): nid %d source %d %s\n",
3656 hdac_audio_ctl_ossmixer_mask2allname(
3657 src, buf, sizeof(buf)),
3658 nid, i, muted?"mute":"unmute");
3659 );
3660 } else {
3661 if (w->nconns == 1)
3662 break;
3663 if ((src & cw->ossmask) == 0)
3664 continue;
3665 /* If we found requested source - select it and exit. */
3666 hdac_widget_connection_select(w, i);
3659 device_printf(pdevinfo->dev,
3660 "Recsel (%s): nid %d source %d %s\n",
3661 hdac_audio_ctl_ossmixer_mask2allname(
3662 src, buf, sizeof(buf)),
3663 nid, i, muted?"mute":"unmute");
3664 );
3665 } else {
3666 if (w->nconns == 1)
3667 break;
3668 if ((src & cw->ossmask) == 0)
3669 continue;
3670 /* If we found requested source - select it and exit. */
3671 hdac_widget_connection_select(w, i);
3667 HDA_BOOTVERBOSE(
3672 HDA_BOOTHVERBOSE(
3668 device_printf(pdevinfo->dev,
3669 "Recsel (%s): nid %d source %d select\n",
3670 hdac_audio_ctl_ossmixer_mask2allname(
3671 src, buf, sizeof(buf)),
3672 nid, i);
3673 );
3674 break;
3675 }

--- 120 unchanged lines hidden (view full) ---

3796 sc->codecs[i] = NULL;
3797
3798 pci_enable_busmaster(dev);
3799
3800 if (vendor == INTEL_VENDORID) {
3801 /* TCSEL -> TC0 */
3802 v = pci_read_config(dev, 0x44, 1);
3803 pci_write_config(dev, 0x44, v & 0xf8, 1);
3673 device_printf(pdevinfo->dev,
3674 "Recsel (%s): nid %d source %d select\n",
3675 hdac_audio_ctl_ossmixer_mask2allname(
3676 src, buf, sizeof(buf)),
3677 nid, i);
3678 );
3679 break;
3680 }

--- 120 unchanged lines hidden (view full) ---

3801 sc->codecs[i] = NULL;
3802
3803 pci_enable_busmaster(dev);
3804
3805 if (vendor == INTEL_VENDORID) {
3806 /* TCSEL -> TC0 */
3807 v = pci_read_config(dev, 0x44, 1);
3808 pci_write_config(dev, 0x44, v & 0xf8, 1);
3804 HDA_BOOTVERBOSE(
3809 HDA_BOOTHVERBOSE(
3805 device_printf(dev, "TCSEL: 0x%02d -> 0x%02d\n", v,
3806 pci_read_config(dev, 0x44, 1));
3807 );
3808 }
3809
3810#ifdef HDAC_MSI_ENABLED
3811 if (resource_int_value(device_get_name(dev),
3812 device_get_unit(dev), "msi", &i) == 0 && i != 0 &&

--- 47 unchanged lines hidden (view full) ---

3860#endif
3861 }
3862 break;
3863 }
3864#if defined(__i386__) || defined(__amd64__)
3865 }
3866#endif
3867
3810 device_printf(dev, "TCSEL: 0x%02d -> 0x%02d\n", v,
3811 pci_read_config(dev, 0x44, 1));
3812 );
3813 }
3814
3815#ifdef HDAC_MSI_ENABLED
3816 if (resource_int_value(device_get_name(dev),
3817 device_get_unit(dev), "msi", &i) == 0 && i != 0 &&

--- 47 unchanged lines hidden (view full) ---

3865#endif
3866 }
3867 break;
3868 }
3869#if defined(__i386__) || defined(__amd64__)
3870 }
3871#endif
3872
3868 HDA_BOOTVERBOSE(
3873 HDA_BOOTHVERBOSE(
3869 device_printf(dev, "DMA Coherency: %s / vendor=0x%04x\n",
3870 (sc->flags & HDAC_F_DMA_NOCACHE) ?
3871 "Uncacheable" : "PCIe snoop", vendor);
3872 );
3873
3874 /* Allocate resources */
3875 result = hdac_mem_alloc(sc);
3876 if (result != 0)

--- 13 unchanged lines hidden (view full) ---

3890 if (result != 0)
3891 goto hdac_attach_fail;
3892 result = hdac_dma_alloc(sc, &sc->rirb_dma,
3893 sc->rirb_size * sizeof(struct hdac_rirb));
3894 if (result != 0)
3895 goto hdac_attach_fail;
3896
3897 /* Quiesce everything */
3874 device_printf(dev, "DMA Coherency: %s / vendor=0x%04x\n",
3875 (sc->flags & HDAC_F_DMA_NOCACHE) ?
3876 "Uncacheable" : "PCIe snoop", vendor);
3877 );
3878
3879 /* Allocate resources */
3880 result = hdac_mem_alloc(sc);
3881 if (result != 0)

--- 13 unchanged lines hidden (view full) ---

3895 if (result != 0)
3896 goto hdac_attach_fail;
3897 result = hdac_dma_alloc(sc, &sc->rirb_dma,
3898 sc->rirb_size * sizeof(struct hdac_rirb));
3899 if (result != 0)
3900 goto hdac_attach_fail;
3901
3902 /* Quiesce everything */
3898 HDA_BOOTVERBOSE(
3903 HDA_BOOTHVERBOSE(
3899 device_printf(dev, "Reset controller...\n");
3900 );
3901 hdac_reset(sc, 1);
3902
3903 /* Initialize the CORB and RIRB */
3904 hdac_corb_init(sc);
3905 hdac_rirb_init(sc);
3906

--- 31 unchanged lines hidden (view full) ---

3938 cad = devinfo->codec->cad;
3939 nid = devinfo->nid;
3940
3941 res = hdac_command(sc,
3942 HDA_CMD_GET_PARAMETER(cad , nid, HDA_PARAM_GPIO_COUNT), cad);
3943 devinfo->function.audio.gpio = res;
3944
3945 HDA_BOOTVERBOSE(
3904 device_printf(dev, "Reset controller...\n");
3905 );
3906 hdac_reset(sc, 1);
3907
3908 /* Initialize the CORB and RIRB */
3909 hdac_corb_init(sc);
3910 hdac_rirb_init(sc);
3911

--- 31 unchanged lines hidden (view full) ---

3943 cad = devinfo->codec->cad;
3944 nid = devinfo->nid;
3945
3946 res = hdac_command(sc,
3947 HDA_CMD_GET_PARAMETER(cad , nid, HDA_PARAM_GPIO_COUNT), cad);
3948 devinfo->function.audio.gpio = res;
3949
3950 HDA_BOOTVERBOSE(
3946 device_printf(sc->dev, " GPIO: 0x%08x\n",
3947 devinfo->function.audio.gpio);
3948 device_printf(sc->dev, " NumGPIO=%d NumGPO=%d "
3951 device_printf(sc->dev, "GPIO: 0x%08x "
3952 "NumGPIO=%d NumGPO=%d "
3949 "NumGPI=%d GPIWake=%d GPIUnsol=%d\n",
3953 "NumGPI=%d GPIWake=%d GPIUnsol=%d\n",
3954 devinfo->function.audio.gpio,
3950 HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->function.audio.gpio),
3951 HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->function.audio.gpio),
3952 HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->function.audio.gpio),
3953 HDA_PARAM_GPIO_COUNT_GPI_WAKE(devinfo->function.audio.gpio),
3954 HDA_PARAM_GPIO_COUNT_GPI_UNSOL(devinfo->function.audio.gpio));
3955 );
3956
3957 res = hdac_command(sc,

--- 309 unchanged lines hidden (view full) ---

4267 if (j != 15 && as[cnt].pincnt > 0) {
4268 if (hpredir && as[cnt].pincnt > 1)
4269 as[cnt].hpredir = first;
4270 cnt++;
4271 }
4272 }
4273 HDA_BOOTVERBOSE(
4274 device_printf(sc->dev,
3955 HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->function.audio.gpio),
3956 HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->function.audio.gpio),
3957 HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->function.audio.gpio),
3958 HDA_PARAM_GPIO_COUNT_GPI_WAKE(devinfo->function.audio.gpio),
3959 HDA_PARAM_GPIO_COUNT_GPI_UNSOL(devinfo->function.audio.gpio));
3960 );
3961
3962 res = hdac_command(sc,

--- 309 unchanged lines hidden (view full) ---

4272 if (j != 15 && as[cnt].pincnt > 0) {
4273 if (hpredir && as[cnt].pincnt > 1)
4274 as[cnt].hpredir = first;
4275 cnt++;
4276 }
4277 }
4278 HDA_BOOTVERBOSE(
4279 device_printf(sc->dev,
4275 "%d associations found\n", max);
4280 "%d associations found:\n", max);
4276 for (i = 0; i < max; i++) {
4277 device_printf(sc->dev,
4278 "Association %d (%d) %s%s:\n",
4279 i, as[i].index, (as[i].dir == HDA_CTL_IN)?"in":"out",
4280 as[i].enable?"":" (disabled)");
4281 for (j = 0; j < 16; j++) {
4282 if (as[i].pins[j] == 0)
4283 continue;
4284 device_printf(sc->dev,
4281 for (i = 0; i < max; i++) {
4282 device_printf(sc->dev,
4283 "Association %d (%d) %s%s:\n",
4284 i, as[i].index, (as[i].dir == HDA_CTL_IN)?"in":"out",
4285 as[i].enable?"":" (disabled)");
4286 for (j = 0; j < 16; j++) {
4287 if (as[i].pins[j] == 0)
4288 continue;
4289 device_printf(sc->dev,
4285 " Pin nid=%d seq=%d\n",
4290 " Pin nid=%d seq=%d\n",
4286 as[i].pins[j], j);
4287 }
4288 }
4289 );
4290
4291 devinfo->function.audio.as = as;
4292}
4293

--- 140 unchanged lines hidden (view full) ---

4434 int i, im = -1;
4435 nid_t m = 0, ret;
4436
4437 if (depth > HDA_PARSE_MAXDEPTH)
4438 return (0);
4439 w = hdac_widget_get(devinfo, nid);
4440 if (w == NULL || w->enable == 0)
4441 return (0);
4291 as[i].pins[j], j);
4292 }
4293 }
4294 );
4295
4296 devinfo->function.audio.as = as;
4297}
4298

--- 140 unchanged lines hidden (view full) ---

4439 int i, im = -1;
4440 nid_t m = 0, ret;
4441
4442 if (depth > HDA_PARSE_MAXDEPTH)
4443 return (0);
4444 w = hdac_widget_get(devinfo, nid);
4445 if (w == NULL || w->enable == 0)
4446 return (0);
4442 HDA_BOOTVERBOSE(
4447 HDA_BOOTHVERBOSE(
4443 if (!only) {
4444 device_printf(devinfo->codec->sc->dev,
4445 " %*stracing via nid %d\n",
4446 depth + 1, "", w->nid);
4447 }
4448 );
4449 /* Use only unused widgets */
4450 if (w->bindas >= 0 && w->bindas != as) {
4448 if (!only) {
4449 device_printf(devinfo->codec->sc->dev,
4450 " %*stracing via nid %d\n",
4451 depth + 1, "", w->nid);
4452 }
4453 );
4454 /* Use only unused widgets */
4455 if (w->bindas >= 0 && w->bindas != as) {
4451 HDA_BOOTVERBOSE(
4456 HDA_BOOTHVERBOSE(
4452 if (!only) {
4453 device_printf(devinfo->codec->sc->dev,
4454 " %*snid %d busy by association %d\n",
4455 depth + 1, "", w->nid, w->bindas);
4456 }
4457 );
4458 return (0);
4459 }
4460 if (dupseq < 0) {
4461 if (w->bindseqmask != 0) {
4457 if (!only) {
4458 device_printf(devinfo->codec->sc->dev,
4459 " %*snid %d busy by association %d\n",
4460 depth + 1, "", w->nid, w->bindas);
4461 }
4462 );
4463 return (0);
4464 }
4465 if (dupseq < 0) {
4466 if (w->bindseqmask != 0) {
4462 HDA_BOOTVERBOSE(
4467 HDA_BOOTHVERBOSE(
4463 if (!only) {
4464 device_printf(devinfo->codec->sc->dev,
4465 " %*snid %d busy by seqmask %x\n",
4466 depth + 1, "", w->nid, w->bindseqmask);
4467 }
4468 );
4469 return (0);
4470 }
4471 } else {
4472 /* If this is headphones - allow duplicate first pin. */
4473 if (w->bindseqmask != 0 &&
4474 (w->bindseqmask & (1 << dupseq)) == 0) {
4468 if (!only) {
4469 device_printf(devinfo->codec->sc->dev,
4470 " %*snid %d busy by seqmask %x\n",
4471 depth + 1, "", w->nid, w->bindseqmask);
4472 }
4473 );
4474 return (0);
4475 }
4476 } else {
4477 /* If this is headphones - allow duplicate first pin. */
4478 if (w->bindseqmask != 0 &&
4479 (w->bindseqmask & (1 << dupseq)) == 0) {
4475 HDA_BOOTVERBOSE(
4480 HDA_BOOTHVERBOSE(
4476 device_printf(devinfo->codec->sc->dev,
4477 " %*snid %d busy by seqmask %x\n",
4478 depth + 1, "", w->nid, w->bindseqmask);
4479 );
4480 return (0);
4481 }
4482 }
4483

--- 35 unchanged lines hidden (view full) ---

4519 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR))
4520 w->selconn = im;
4521 break;
4522 }
4523 if (m && only) {
4524 w->bindas = as;
4525 w->bindseqmask |= (1 << seq);
4526 }
4481 device_printf(devinfo->codec->sc->dev,
4482 " %*snid %d busy by seqmask %x\n",
4483 depth + 1, "", w->nid, w->bindseqmask);
4484 );
4485 return (0);
4486 }
4487 }
4488

--- 35 unchanged lines hidden (view full) ---

4524 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR))
4525 w->selconn = im;
4526 break;
4527 }
4528 if (m && only) {
4529 w->bindas = as;
4530 w->bindseqmask |= (1 << seq);
4531 }
4527 HDA_BOOTVERBOSE(
4532 HDA_BOOTHVERBOSE(
4528 if (!only) {
4529 device_printf(devinfo->codec->sc->dev,
4530 " %*snid %d returned %d\n",
4531 depth + 1, "", w->nid, m);
4532 }
4533 );
4534 return (m);
4535}

--- 9 unchanged lines hidden (view full) ---

4545 int i, j;
4546 nid_t res = 0;
4547
4548 if (depth > HDA_PARSE_MAXDEPTH)
4549 return (0);
4550 w = hdac_widget_get(devinfo, nid);
4551 if (w == NULL || w->enable == 0)
4552 return (0);
4533 if (!only) {
4534 device_printf(devinfo->codec->sc->dev,
4535 " %*snid %d returned %d\n",
4536 depth + 1, "", w->nid, m);
4537 }
4538 );
4539 return (m);
4540}

--- 9 unchanged lines hidden (view full) ---

4550 int i, j;
4551 nid_t res = 0;
4552
4553 if (depth > HDA_PARSE_MAXDEPTH)
4554 return (0);
4555 w = hdac_widget_get(devinfo, nid);
4556 if (w == NULL || w->enable == 0)
4557 return (0);
4553 HDA_BOOTVERBOSE(
4558 HDA_BOOTHVERBOSE(
4554 device_printf(devinfo->codec->sc->dev,
4555 " %*stracing via nid %d\n",
4556 depth + 1, "", w->nid);
4557 );
4558 /* Use only unused widgets */
4559 if (w->bindas >= 0 && w->bindas != as) {
4559 device_printf(devinfo->codec->sc->dev,
4560 " %*stracing via nid %d\n",
4561 depth + 1, "", w->nid);
4562 );
4563 /* Use only unused widgets */
4564 if (w->bindas >= 0 && w->bindas != as) {
4560 HDA_BOOTVERBOSE(
4565 HDA_BOOTHVERBOSE(
4561 device_printf(devinfo->codec->sc->dev,
4562 " %*snid %d busy by association %d\n",
4563 depth + 1, "", w->nid, w->bindas);
4564 );
4565 return (0);
4566 }
4567
4568 switch (w->type) {

--- 29 unchanged lines hidden (view full) ---

4598 }
4599 }
4600 break;
4601 }
4602 if (res) {
4603 w->bindas = as;
4604 w->bindseqmask |= (1 << seq);
4605 }
4566 device_printf(devinfo->codec->sc->dev,
4567 " %*snid %d busy by association %d\n",
4568 depth + 1, "", w->nid, w->bindas);
4569 );
4570 return (0);
4571 }
4572
4573 switch (w->type) {

--- 29 unchanged lines hidden (view full) ---

4603 }
4604 }
4605 break;
4606 }
4607 if (res) {
4608 w->bindas = as;
4609 w->bindseqmask |= (1 << seq);
4610 }
4606 HDA_BOOTVERBOSE(
4611 HDA_BOOTHVERBOSE(
4607 device_printf(devinfo->codec->sc->dev,
4608 " %*snid %d returned %d\n",
4609 depth + 1, "", w->nid, res);
4610 );
4611 return (res);
4612}
4613
4614/*

--- 41 unchanged lines hidden (view full) ---

4656 /* Check if there is no any left. If so - we succeded. */
4657 if (i == 16)
4658 return (1);
4659
4660 hpredir = (i == 15 && ases[as].fakeredir == 0)?ases[as].hpredir:-1;
4661 min = 0;
4662 res = 0;
4663 do {
4612 device_printf(devinfo->codec->sc->dev,
4613 " %*snid %d returned %d\n",
4614 depth + 1, "", w->nid, res);
4615 );
4616 return (res);
4617}
4618
4619/*

--- 41 unchanged lines hidden (view full) ---

4661 /* Check if there is no any left. If so - we succeded. */
4662 if (i == 16)
4663 return (1);
4664
4665 hpredir = (i == 15 && ases[as].fakeredir == 0)?ases[as].hpredir:-1;
4666 min = 0;
4667 res = 0;
4668 do {
4664 HDA_BOOTVERBOSE(
4669 HDA_BOOTHVERBOSE(
4665 device_printf(devinfo->codec->sc->dev,
4666 " Tracing pin %d with min nid %d",
4667 ases[as].pins[i], min);
4668 if (hpredir >= 0)
4670 device_printf(devinfo->codec->sc->dev,
4671 " Tracing pin %d with min nid %d",
4672 ases[as].pins[i], min);
4673 if (hpredir >= 0)
4669 printf(" and hpredir %d\n", hpredir);
4670 else
4671 printf("\n");
4674 printf(" and hpredir %d", hpredir);
4675 printf("\n");
4672 );
4673 /* Trace this pin taking min nid into account. */
4674 res = hdac_audio_trace_dac(devinfo, as, i,
4675 ases[as].pins[i], hpredir, min, 0, 0);
4676 if (res == 0) {
4677 /* If we failed - return to previous and redo it. */
4678 HDA_BOOTVERBOSE(
4679 device_printf(devinfo->codec->sc->dev,
4680 " Unable to trace pin %d seq %d with min "
4676 );
4677 /* Trace this pin taking min nid into account. */
4678 res = hdac_audio_trace_dac(devinfo, as, i,
4679 ases[as].pins[i], hpredir, min, 0, 0);
4680 if (res == 0) {
4681 /* If we failed - return to previous and redo it. */
4682 HDA_BOOTVERBOSE(
4683 device_printf(devinfo->codec->sc->dev,
4684 " Unable to trace pin %d seq %d with min "
4681 "nid %d hpredir %d\n",
4682 ases[as].pins[i], i, min, hpredir);
4685 "nid %d",
4686 ases[as].pins[i], i, min);
4687 if (hpredir >= 0)
4688 printf(" and hpredir %d", hpredir);
4689 printf("\n");
4683 );
4684 return (0);
4685 }
4686 HDA_BOOTVERBOSE(
4687 device_printf(devinfo->codec->sc->dev,
4690 );
4691 return (0);
4692 }
4693 HDA_BOOTVERBOSE(
4694 device_printf(devinfo->codec->sc->dev,
4688 " Pin %d traced to DAC %d%s\n",
4689 ases[as].pins[i], res,
4690 ases[as].fakeredir?" with fake redirection":"");
4695 " Pin %d traced to DAC %d",
4696 ases[as].pins[i], res);
4697 if (hpredir >= 0)
4698 printf(" and hpredir %d", hpredir);
4699 if (ases[as].fakeredir)
4700 printf(" with fake redirection");
4701 printf("\n");
4691 );
4692 /* Trace again to mark the path */
4693 hdac_audio_trace_dac(devinfo, as, i,
4694 ases[as].pins[i], hpredir, min, res, 0);
4695 ases[as].dacs[i] = res;
4696 /* We succeded, so call next. */
4697 if (hdac_audio_trace_as_out(devinfo, as, i + 1))
4698 return (1);

--- 23 unchanged lines hidden (view full) ---

4722 if (w->bindas >= 0 && w->bindas != as)
4723 continue;
4724
4725 /* Find next pin */
4726 for (i = 0; i < 16; i++) {
4727 if (ases[as].pins[i] == 0)
4728 continue;
4729
4702 );
4703 /* Trace again to mark the path */
4704 hdac_audio_trace_dac(devinfo, as, i,
4705 ases[as].pins[i], hpredir, min, res, 0);
4706 ases[as].dacs[i] = res;
4707 /* We succeded, so call next. */
4708 if (hdac_audio_trace_as_out(devinfo, as, i + 1))
4709 return (1);

--- 23 unchanged lines hidden (view full) ---

4733 if (w->bindas >= 0 && w->bindas != as)
4734 continue;
4735
4736 /* Find next pin */
4737 for (i = 0; i < 16; i++) {
4738 if (ases[as].pins[i] == 0)
4739 continue;
4740
4730 HDA_BOOTVERBOSE(
4741 HDA_BOOTHVERBOSE(
4731 device_printf(devinfo->codec->sc->dev,
4732 " Tracing pin %d to ADC %d\n",
4733 ases[as].pins[i], j);
4734 );
4735 /* Trace this pin taking goal into account. */
4736 if (hdac_audio_trace_adc(devinfo, as, i,
4737 ases[as].pins[i], j, 0) == 0) {
4738 /* If we failed - return to previous and redo it. */
4739 HDA_BOOTVERBOSE(
4740 device_printf(devinfo->codec->sc->dev,
4742 device_printf(devinfo->codec->sc->dev,
4743 " Tracing pin %d to ADC %d\n",
4744 ases[as].pins[i], j);
4745 );
4746 /* Trace this pin taking goal into account. */
4747 if (hdac_audio_trace_adc(devinfo, as, i,
4748 ases[as].pins[i], j, 0) == 0) {
4749 /* If we failed - return to previous and redo it. */
4750 HDA_BOOTVERBOSE(
4751 device_printf(devinfo->codec->sc->dev,
4741 " Unable to trace pin %d to ADC %d\n",
4752 " Unable to trace pin %d to ADC %d, undo traces\n",
4742 ases[as].pins[i], j);
4743 );
4744 hdac_audio_undo_trace(devinfo, as, -1);
4745 for (k = 0; k < 16; k++)
4746 ases[as].dacs[k] = 0;
4747 break;
4748 }
4749 HDA_BOOTVERBOSE(
4750 device_printf(devinfo->codec->sc->dev,
4753 ases[as].pins[i], j);
4754 );
4755 hdac_audio_undo_trace(devinfo, as, -1);
4756 for (k = 0; k < 16; k++)
4757 ases[as].dacs[k] = 0;
4758 break;
4759 }
4760 HDA_BOOTVERBOSE(
4761 device_printf(devinfo->codec->sc->dev,
4751 " Traced to ADC %d\n",
4752 j);
4762 " Pin %d traced to ADC %d\n",
4763 ases[as].pins[i], j);
4753 );
4754 ases[as].dacs[i] = j;
4755 }
4756 if (i == 16)
4757 return (1);
4758 }
4759 return (0);
4760}
4761
4762/*
4763 * Trace input monitor path from mixer to output association.
4764 */
4764 );
4765 ases[as].dacs[i] = j;
4766 }
4767 if (i == 16)
4768 return (1);
4769 }
4770 return (0);
4771}
4772
4773/*
4774 * Trace input monitor path from mixer to output association.
4775 */
4765static nid_t
4776static int
4766hdac_audio_trace_to_out(struct hdac_devinfo *devinfo, nid_t nid, int depth)
4767{
4768 struct hdac_audio_as *ases = devinfo->function.audio.as;
4769 struct hdac_widget *w, *wc;
4770 int i, j;
4771 nid_t res = 0;
4772
4773 if (depth > HDA_PARSE_MAXDEPTH)
4774 return (0);
4775 w = hdac_widget_get(devinfo, nid);
4776 if (w == NULL || w->enable == 0)
4777 return (0);
4777hdac_audio_trace_to_out(struct hdac_devinfo *devinfo, nid_t nid, int depth)
4778{
4779 struct hdac_audio_as *ases = devinfo->function.audio.as;
4780 struct hdac_widget *w, *wc;
4781 int i, j;
4782 nid_t res = 0;
4783
4784 if (depth > HDA_PARSE_MAXDEPTH)
4785 return (0);
4786 w = hdac_widget_get(devinfo, nid);
4787 if (w == NULL || w->enable == 0)
4788 return (0);
4778 HDA_BOOTVERBOSE(
4789 HDA_BOOTHVERBOSE(
4779 device_printf(devinfo->codec->sc->dev,
4780 " %*stracing via nid %d\n",
4781 depth + 1, "", w->nid);
4782 );
4783 /* Use only unused widgets */
4784 if (depth > 0 && w->bindas != -1) {
4785 if (w->bindas < 0 || ases[w->bindas].dir == HDA_CTL_OUT) {
4790 device_printf(devinfo->codec->sc->dev,
4791 " %*stracing via nid %d\n",
4792 depth + 1, "", w->nid);
4793 );
4794 /* Use only unused widgets */
4795 if (depth > 0 && w->bindas != -1) {
4796 if (w->bindas < 0 || ases[w->bindas].dir == HDA_CTL_OUT) {
4786 HDA_BOOTVERBOSE(
4797 HDA_BOOTHVERBOSE(
4787 device_printf(devinfo->codec->sc->dev,
4788 " %*snid %d found output association %d\n",
4789 depth + 1, "", w->nid, w->bindas);
4790 );
4791 return (1);
4792 } else {
4798 device_printf(devinfo->codec->sc->dev,
4799 " %*snid %d found output association %d\n",
4800 depth + 1, "", w->nid, w->bindas);
4801 );
4802 return (1);
4803 } else {
4793 HDA_BOOTVERBOSE(
4804 HDA_BOOTHVERBOSE(
4794 device_printf(devinfo->codec->sc->dev,
4795 " %*snid %d busy by input association %d\n",
4796 depth + 1, "", w->nid, w->bindas);
4797 );
4798 return (0);
4799 }
4800 }
4801

--- 26 unchanged lines hidden (view full) ---

4828 }
4829 }
4830 }
4831 break;
4832 }
4833 if (res)
4834 w->bindas = -2;
4835
4805 device_printf(devinfo->codec->sc->dev,
4806 " %*snid %d busy by input association %d\n",
4807 depth + 1, "", w->nid, w->bindas);
4808 );
4809 return (0);
4810 }
4811 }
4812

--- 26 unchanged lines hidden (view full) ---

4839 }
4840 }
4841 }
4842 break;
4843 }
4844 if (res)
4845 w->bindas = -2;
4846
4836 HDA_BOOTVERBOSE(
4847 HDA_BOOTHVERBOSE(
4837 device_printf(devinfo->codec->sc->dev,
4838 " %*snid %d returned %d\n",
4839 depth + 1, "", w->nid, res);
4840 );
4841 return (res);
4842}
4843
4844/*

--- 43 unchanged lines hidden (view full) ---

4888 "Tracing beeper\n");
4889 );
4890 for (j = devinfo->startnode; j < devinfo->endnode; j++) {
4891 w = hdac_widget_get(devinfo, j);
4892 if (w == NULL || w->enable == 0)
4893 continue;
4894 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_BEEP_WIDGET)
4895 continue;
4848 device_printf(devinfo->codec->sc->dev,
4849 " %*snid %d returned %d\n",
4850 depth + 1, "", w->nid, res);
4851 );
4852 return (res);
4853}
4854
4855/*

--- 43 unchanged lines hidden (view full) ---

4899 "Tracing beeper\n");
4900 );
4901 for (j = devinfo->startnode; j < devinfo->endnode; j++) {
4902 w = hdac_widget_get(devinfo, j);
4903 if (w == NULL || w->enable == 0)
4904 continue;
4905 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_BEEP_WIDGET)
4906 continue;
4896 HDA_BOOTVERBOSE(
4907 HDA_BOOTHVERBOSE(
4897 device_printf(devinfo->codec->sc->dev,
4898 " Tracing nid %d to out\n",
4899 j);
4900 );
4908 device_printf(devinfo->codec->sc->dev,
4909 " Tracing nid %d to out\n",
4910 j);
4911 );
4901 hdac_audio_trace_to_out(devinfo, w->nid, 0);
4912 if (hdac_audio_trace_to_out(devinfo, w->nid, 0)) {
4913 HDA_BOOTVERBOSE(
4914 device_printf(devinfo->codec->sc->dev,
4915 " nid %d traced to out\n",
4916 j);
4917 );
4918 }
4902 w->bindas = -2;
4903 }
4904}
4905
4906/*
4907 * Bind assotiations to PCM channels
4908 */
4909static void

--- 64 unchanged lines hidden (view full) ---

4974 /* Disable power and volume widgets. */
4975 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4976 w = hdac_widget_get(devinfo, i);
4977 if (w == NULL || w->enable == 0)
4978 continue;
4979 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_POWER_WIDGET ||
4980 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_VOLUME_WIDGET) {
4981 w->enable = 0;
4919 w->bindas = -2;
4920 }
4921}
4922
4923/*
4924 * Bind assotiations to PCM channels
4925 */
4926static void

--- 64 unchanged lines hidden (view full) ---

4991 /* Disable power and volume widgets. */
4992 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4993 w = hdac_widget_get(devinfo, i);
4994 if (w == NULL || w->enable == 0)
4995 continue;
4996 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_POWER_WIDGET ||
4997 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_VOLUME_WIDGET) {
4998 w->enable = 0;
4982 HDA_BOOTVERBOSE(
4999 HDA_BOOTHVERBOSE(
4983 device_printf(devinfo->codec->sc->dev,
4984 " Disabling nid %d due to it's"
4985 " non-audio type.\n",
4986 w->nid);
4987 );
4988 }
4989 }
4990}

--- 10 unchanged lines hidden (view full) ---

5001 w = hdac_widget_get(devinfo, i);
5002 if (w == NULL || w->enable == 0)
5003 continue;
5004 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
5005 (w->wclass.pin.config &
5006 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK) ==
5007 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_NONE) {
5008 w->enable = 0;
5000 device_printf(devinfo->codec->sc->dev,
5001 " Disabling nid %d due to it's"
5002 " non-audio type.\n",
5003 w->nid);
5004 );
5005 }
5006 }
5007}

--- 10 unchanged lines hidden (view full) ---

5018 w = hdac_widget_get(devinfo, i);
5019 if (w == NULL || w->enable == 0)
5020 continue;
5021 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
5022 (w->wclass.pin.config &
5023 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK) ==
5024 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_NONE) {
5025 w->enable = 0;
5009 HDA_BOOTVERBOSE(
5026 HDA_BOOTHVERBOSE(
5010 device_printf(devinfo->codec->sc->dev,
5011 " Disabling pin nid %d due"
5012 " to None connectivity.\n",
5013 w->nid);
5014 );
5015 }
5016 }
5017 do {

--- 9 unchanged lines hidden (view full) ---

5027 ctl->forcemute = 1;
5028 ctl->muted = HDA_AMP_MUTE_ALL;
5029 ctl->left = 0;
5030 ctl->right = 0;
5031 ctl->enable = 0;
5032 if (ctl->ndir == HDA_CTL_IN)
5033 ctl->widget->connsenable[ctl->index] = 0;
5034 done = 0;
5027 device_printf(devinfo->codec->sc->dev,
5028 " Disabling pin nid %d due"
5029 " to None connectivity.\n",
5030 w->nid);
5031 );
5032 }
5033 }
5034 do {

--- 9 unchanged lines hidden (view full) ---

5044 ctl->forcemute = 1;
5045 ctl->muted = HDA_AMP_MUTE_ALL;
5046 ctl->left = 0;
5047 ctl->right = 0;
5048 ctl->enable = 0;
5049 if (ctl->ndir == HDA_CTL_IN)
5050 ctl->widget->connsenable[ctl->index] = 0;
5051 done = 0;
5035 HDA_BOOTVERBOSE(
5052 HDA_BOOTHVERBOSE(
5036 device_printf(devinfo->codec->sc->dev,
5037 " Disabling ctl %d nid %d cnid %d due"
5038 " to disabled widget.\n", i,
5039 ctl->widget->nid,
5040 (ctl->childwidget != NULL)?
5041 ctl->childwidget->nid:-1);
5042 );
5043 }

--- 4 unchanged lines hidden (view full) ---

5048 if (w == NULL || w->enable == 0)
5049 continue;
5050 /* Disable inputs with disabled child widgets. */
5051 for (j = 0; j < w->nconns; j++) {
5052 if (w->connsenable[j]) {
5053 cw = hdac_widget_get(devinfo, w->conns[j]);
5054 if (cw == NULL || cw->enable == 0) {
5055 w->connsenable[j] = 0;
5053 device_printf(devinfo->codec->sc->dev,
5054 " Disabling ctl %d nid %d cnid %d due"
5055 " to disabled widget.\n", i,
5056 ctl->widget->nid,
5057 (ctl->childwidget != NULL)?
5058 ctl->childwidget->nid:-1);
5059 );
5060 }

--- 4 unchanged lines hidden (view full) ---

5065 if (w == NULL || w->enable == 0)
5066 continue;
5067 /* Disable inputs with disabled child widgets. */
5068 for (j = 0; j < w->nconns; j++) {
5069 if (w->connsenable[j]) {
5070 cw = hdac_widget_get(devinfo, w->conns[j]);
5071 if (cw == NULL || cw->enable == 0) {
5072 w->connsenable[j] = 0;
5056 HDA_BOOTVERBOSE(
5073 HDA_BOOTHVERBOSE(
5057 device_printf(devinfo->codec->sc->dev,
5058 " Disabling nid %d connection %d due"
5059 " to disabled child widget.\n",
5060 i, j);
5061 );
5062 }
5063 }
5064 }

--- 6 unchanged lines hidden (view full) ---

5071 if (w->connsenable[j]) {
5072 found = 1;
5073 break;
5074 }
5075 }
5076 if (found == 0) {
5077 w->enable = 0;
5078 done = 0;
5074 device_printf(devinfo->codec->sc->dev,
5075 " Disabling nid %d connection %d due"
5076 " to disabled child widget.\n",
5077 i, j);
5078 );
5079 }
5080 }
5081 }

--- 6 unchanged lines hidden (view full) ---

5088 if (w->connsenable[j]) {
5089 found = 1;
5090 break;
5091 }
5092 }
5093 if (found == 0) {
5094 w->enable = 0;
5095 done = 0;
5079 HDA_BOOTVERBOSE(
5096 HDA_BOOTHVERBOSE(
5080 device_printf(devinfo->codec->sc->dev,
5081 " Disabling nid %d due to all it's"
5082 " inputs disabled.\n", w->nid);
5083 );
5084 }
5085 /* Disable nodes without consumers. */
5086 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR &&
5087 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)

--- 8 unchanged lines hidden (view full) ---

5096 found = 1;
5097 break;
5098 }
5099 }
5100 }
5101 if (found == 0) {
5102 w->enable = 0;
5103 done = 0;
5097 device_printf(devinfo->codec->sc->dev,
5098 " Disabling nid %d due to all it's"
5099 " inputs disabled.\n", w->nid);
5100 );
5101 }
5102 /* Disable nodes without consumers. */
5103 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR &&
5104 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)

--- 8 unchanged lines hidden (view full) ---

5113 found = 1;
5114 break;
5115 }
5116 }
5117 }
5118 if (found == 0) {
5119 w->enable = 0;
5120 done = 0;
5104 HDA_BOOTVERBOSE(
5121 HDA_BOOTHVERBOSE(
5105 device_printf(devinfo->codec->sc->dev,
5106 " Disabling nid %d due to all it's"
5107 " consumers disabled.\n", w->nid);
5108 );
5109 }
5110 }
5111 } while (done == 0);
5112

--- 9 unchanged lines hidden (view full) ---

5122
5123 /* Disable unassosiated widgets. */
5124 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
5125 w = hdac_widget_get(devinfo, i);
5126 if (w == NULL || w->enable == 0)
5127 continue;
5128 if (w->bindas == -1) {
5129 w->enable = 0;
5122 device_printf(devinfo->codec->sc->dev,
5123 " Disabling nid %d due to all it's"
5124 " consumers disabled.\n", w->nid);
5125 );
5126 }
5127 }
5128 } while (done == 0);
5129

--- 9 unchanged lines hidden (view full) ---

5139
5140 /* Disable unassosiated widgets. */
5141 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
5142 w = hdac_widget_get(devinfo, i);
5143 if (w == NULL || w->enable == 0)
5144 continue;
5145 if (w->bindas == -1) {
5146 w->enable = 0;
5130 HDA_BOOTVERBOSE(
5147 HDA_BOOTHVERBOSE(
5131 device_printf(devinfo->codec->sc->dev,
5132 " Disabling unassociated nid %d.\n",
5133 w->nid);
5134 );
5135 }
5136 }
5137 /* Disable input connections on input pin and
5138 * output on output. */

--- 5 unchanged lines hidden (view full) ---

5144 continue;
5145 if (w->bindas < 0)
5146 continue;
5147 if (as[w->bindas].dir == HDA_CTL_IN) {
5148 for (j = 0; j < w->nconns; j++) {
5149 if (w->connsenable[j] == 0)
5150 continue;
5151 w->connsenable[j] = 0;
5148 device_printf(devinfo->codec->sc->dev,
5149 " Disabling unassociated nid %d.\n",
5150 w->nid);
5151 );
5152 }
5153 }
5154 /* Disable input connections on input pin and
5155 * output on output. */

--- 5 unchanged lines hidden (view full) ---

5161 continue;
5162 if (w->bindas < 0)
5163 continue;
5164 if (as[w->bindas].dir == HDA_CTL_IN) {
5165 for (j = 0; j < w->nconns; j++) {
5166 if (w->connsenable[j] == 0)
5167 continue;
5168 w->connsenable[j] = 0;
5152 HDA_BOOTVERBOSE(
5169 HDA_BOOTHVERBOSE(
5153 device_printf(devinfo->codec->sc->dev,
5154 " Disabling connection to input pin "
5155 "nid %d conn %d.\n",
5156 i, j);
5157 );
5158 }
5159 ctl = hdac_audio_ctl_amp_get(devinfo, w->nid,
5160 HDA_CTL_IN, -1, 1);

--- 16 unchanged lines hidden (view full) ---

5177 }
5178 for (k = devinfo->startnode; k < devinfo->endnode; k++) {
5179 cw = hdac_widget_get(devinfo, k);
5180 if (cw == NULL || cw->enable == 0)
5181 continue;
5182 for (j = 0; j < cw->nconns; j++) {
5183 if (cw->connsenable[j] && cw->conns[j] == i) {
5184 cw->connsenable[j] = 0;
5170 device_printf(devinfo->codec->sc->dev,
5171 " Disabling connection to input pin "
5172 "nid %d conn %d.\n",
5173 i, j);
5174 );
5175 }
5176 ctl = hdac_audio_ctl_amp_get(devinfo, w->nid,
5177 HDA_CTL_IN, -1, 1);

--- 16 unchanged lines hidden (view full) ---

5194 }
5195 for (k = devinfo->startnode; k < devinfo->endnode; k++) {
5196 cw = hdac_widget_get(devinfo, k);
5197 if (cw == NULL || cw->enable == 0)
5198 continue;
5199 for (j = 0; j < cw->nconns; j++) {
5200 if (cw->connsenable[j] && cw->conns[j] == i) {
5201 cw->connsenable[j] = 0;
5185 HDA_BOOTVERBOSE(
5202 HDA_BOOTHVERBOSE(
5186 device_printf(devinfo->codec->sc->dev,
5187 " Disabling connection from output pin "
5188 "nid %d conn %d cnid %d.\n",
5189 k, j, i);
5190 );
5191 if (cw->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
5192 cw->nconns > 1)
5193 continue;

--- 32 unchanged lines hidden (view full) ---

5226 if (w->bindas < 0 || as[w->bindas].dir == HDA_CTL_IN)
5227 continue;
5228 for (j = 0; j < w->nconns; j++) {
5229 if (w->connsenable[j] == 0)
5230 continue;
5231 if (w->selconn < 0 || w->selconn == j)
5232 continue;
5233 w->connsenable[j] = 0;
5203 device_printf(devinfo->codec->sc->dev,
5204 " Disabling connection from output pin "
5205 "nid %d conn %d cnid %d.\n",
5206 k, j, i);
5207 );
5208 if (cw->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
5209 cw->nconns > 1)
5210 continue;

--- 32 unchanged lines hidden (view full) ---

5243 if (w->bindas < 0 || as[w->bindas].dir == HDA_CTL_IN)
5244 continue;
5245 for (j = 0; j < w->nconns; j++) {
5246 if (w->connsenable[j] == 0)
5247 continue;
5248 if (w->selconn < 0 || w->selconn == j)
5249 continue;
5250 w->connsenable[j] = 0;
5234 HDA_BOOTVERBOSE(
5251 HDA_BOOTHVERBOSE(
5235 device_printf(devinfo->codec->sc->dev,
5236 " Disabling unselected connection "
5237 "nid %d conn %d.\n",
5238 i, j);
5239 );
5240 }
5241 }
5242}

--- 21 unchanged lines hidden (view full) ---

5264 if (w->connsenable[j] == 0)
5265 continue;
5266 cw = hdac_widget_get(devinfo, w->conns[j]);
5267 if (cw == NULL || w->enable == 0)
5268 continue;
5269 if (w->bindas == cw->bindas || cw->bindas == -2)
5270 continue;
5271 w->connsenable[j] = 0;
5252 device_printf(devinfo->codec->sc->dev,
5253 " Disabling unselected connection "
5254 "nid %d conn %d.\n",
5255 i, j);
5256 );
5257 }
5258 }
5259}

--- 21 unchanged lines hidden (view full) ---

5281 if (w->connsenable[j] == 0)
5282 continue;
5283 cw = hdac_widget_get(devinfo, w->conns[j]);
5284 if (cw == NULL || w->enable == 0)
5285 continue;
5286 if (w->bindas == cw->bindas || cw->bindas == -2)
5287 continue;
5288 w->connsenable[j] = 0;
5272 HDA_BOOTVERBOSE(
5289 HDA_BOOTHVERBOSE(
5273 device_printf(devinfo->codec->sc->dev,
5274 " Disabling crossassociatement connection "
5275 "nid %d conn %d cnid %d.\n",
5276 i, j, cw->nid);
5277 );
5278 }
5279 }
5280 /* ... using controls */

--- 7 unchanged lines hidden (view full) ---

5288 if (ctl->widget->bindas != ctl->childwidget->bindas) {
5289 ctl->forcemute = 1;
5290 ctl->muted = HDA_AMP_MUTE_ALL;
5291 ctl->left = 0;
5292 ctl->right = 0;
5293 ctl->enable = 0;
5294 if (ctl->ndir == HDA_CTL_IN)
5295 ctl->widget->connsenable[ctl->index] = 0;
5290 device_printf(devinfo->codec->sc->dev,
5291 " Disabling crossassociatement connection "
5292 "nid %d conn %d cnid %d.\n",
5293 i, j, cw->nid);
5294 );
5295 }
5296 }
5297 /* ... using controls */

--- 7 unchanged lines hidden (view full) ---

5305 if (ctl->widget->bindas != ctl->childwidget->bindas) {
5306 ctl->forcemute = 1;
5307 ctl->muted = HDA_AMP_MUTE_ALL;
5308 ctl->left = 0;
5309 ctl->right = 0;
5310 ctl->enable = 0;
5311 if (ctl->ndir == HDA_CTL_IN)
5312 ctl->widget->connsenable[ctl->index] = 0;
5296 HDA_BOOTVERBOSE(
5313 HDA_BOOTHVERBOSE(
5297 device_printf(devinfo->codec->sc->dev,
5298 " Disabling crossassociatement connection "
5299 "ctl %d nid %d cnid %d.\n", i,
5300 ctl->widget->nid,
5301 ctl->childwidget->nid);
5302 );
5303 }
5304 }

--- 320 unchanged lines hidden (view full) ---

5625}
5626
5627static void
5628hdac_audio_build_tree(struct hdac_devinfo *devinfo)
5629{
5630 struct hdac_audio_as *as = devinfo->function.audio.as;
5631 int j, res;
5632
5314 device_printf(devinfo->codec->sc->dev,
5315 " Disabling crossassociatement connection "
5316 "ctl %d nid %d cnid %d.\n", i,
5317 ctl->widget->nid,
5318 ctl->childwidget->nid);
5319 );
5320 }
5321 }

--- 320 unchanged lines hidden (view full) ---

5642}
5643
5644static void
5645hdac_audio_build_tree(struct hdac_devinfo *devinfo)
5646{
5647 struct hdac_audio_as *as = devinfo->function.audio.as;
5648 int j, res;
5649
5633 HDA_BOOTVERBOSE(
5634 device_printf(devinfo->codec->sc->dev,
5635 "HWiP: HDA Widget Parser - Revision %d\n",
5636 HDA_WIDGET_PARSER_REV);
5637 );
5638
5639 /* Trace all associations in order of their numbers, */
5640 for (j = 0; j < devinfo->function.audio.ascnt; j++) {
5641 if (as[j].enable == 0)
5642 continue;
5643 HDA_BOOTVERBOSE(
5644 device_printf(devinfo->codec->sc->dev,
5645 "Tracing association %d (%d)\n", j, as[j].index);
5646 );

--- 509 unchanged lines hidden (view full) ---

6156static void
6157hdac_dump_audio_formats(device_t dev, uint32_t fcap, uint32_t pcmcap)
6158{
6159 uint32_t cap;
6160
6161 cap = fcap;
6162 if (cap != 0) {
6163 device_printf(dev, " Stream cap: 0x%08x\n", cap);
5650 /* Trace all associations in order of their numbers, */
5651 for (j = 0; j < devinfo->function.audio.ascnt; j++) {
5652 if (as[j].enable == 0)
5653 continue;
5654 HDA_BOOTVERBOSE(
5655 device_printf(devinfo->codec->sc->dev,
5656 "Tracing association %d (%d)\n", j, as[j].index);
5657 );

--- 509 unchanged lines hidden (view full) ---

6167static void
6168hdac_dump_audio_formats(device_t dev, uint32_t fcap, uint32_t pcmcap)
6169{
6170 uint32_t cap;
6171
6172 cap = fcap;
6173 if (cap != 0) {
6174 device_printf(dev, " Stream cap: 0x%08x\n", cap);
6164 device_printf(dev, " Format:");
6175 device_printf(dev, " ");
6165 if (HDA_PARAM_SUPP_STREAM_FORMATS_AC3(cap))
6166 printf(" AC3");
6167 if (HDA_PARAM_SUPP_STREAM_FORMATS_FLOAT32(cap))
6168 printf(" FLOAT32");
6169 if (HDA_PARAM_SUPP_STREAM_FORMATS_PCM(cap))
6170 printf(" PCM");
6171 printf("\n");
6172 }
6173 cap = pcmcap;
6174 if (cap != 0) {
6175 device_printf(dev, " PCM cap: 0x%08x\n", cap);
6176 if (HDA_PARAM_SUPP_STREAM_FORMATS_AC3(cap))
6177 printf(" AC3");
6178 if (HDA_PARAM_SUPP_STREAM_FORMATS_FLOAT32(cap))
6179 printf(" FLOAT32");
6180 if (HDA_PARAM_SUPP_STREAM_FORMATS_PCM(cap))
6181 printf(" PCM");
6182 printf("\n");
6183 }
6184 cap = pcmcap;
6185 if (cap != 0) {
6186 device_printf(dev, " PCM cap: 0x%08x\n", cap);
6176 device_printf(dev, " PCM size:");
6187 device_printf(dev, " ");
6177 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_8BIT(cap))
6178 printf(" 8");
6179 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_16BIT(cap))
6180 printf(" 16");
6181 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_20BIT(cap))
6182 printf(" 20");
6183 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_24BIT(cap))
6184 printf(" 24");
6185 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_32BIT(cap))
6186 printf(" 32");
6188 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_8BIT(cap))
6189 printf(" 8");
6190 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_16BIT(cap))
6191 printf(" 16");
6192 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_20BIT(cap))
6193 printf(" 20");
6194 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_24BIT(cap))
6195 printf(" 24");
6196 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_32BIT(cap))
6197 printf(" 32");
6187 printf("\n");
6188 device_printf(dev, " PCM rate:");
6198 printf(" bits,");
6189 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_8KHZ(cap))
6190 printf(" 8");
6191 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_11KHZ(cap))
6192 printf(" 11");
6193 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_16KHZ(cap))
6194 printf(" 16");
6195 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_22KHZ(cap))
6196 printf(" 22");

--- 5 unchanged lines hidden (view full) ---

6202 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_88KHZ(cap))
6203 printf(" 88");
6204 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_96KHZ(cap))
6205 printf(" 96");
6206 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_176KHZ(cap))
6207 printf(" 176");
6208 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_192KHZ(cap))
6209 printf(" 192");
6199 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_8KHZ(cap))
6200 printf(" 8");
6201 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_11KHZ(cap))
6202 printf(" 11");
6203 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_16KHZ(cap))
6204 printf(" 16");
6205 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_22KHZ(cap))
6206 printf(" 22");

--- 5 unchanged lines hidden (view full) ---

6212 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_88KHZ(cap))
6213 printf(" 88");
6214 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_96KHZ(cap))
6215 printf(" 96");
6216 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_176KHZ(cap))
6217 printf(" 176");
6218 if (HDA_PARAM_SUPP_PCM_SIZE_RATE_192KHZ(cap))
6219 printf(" 192");
6210 printf("\n");
6220 printf(" KHz\n");
6211 }
6212}
6213
6214static void
6215hdac_dump_pin(struct hdac_softc *sc, struct hdac_widget *w)
6216{
6221 }
6222}
6223
6224static void
6225hdac_dump_pin(struct hdac_softc *sc, struct hdac_widget *w)
6226{
6217 uint32_t pincap, wcap;
6227 uint32_t pincap;
6218
6219 pincap = w->wclass.pin.cap;
6228
6229 pincap = w->wclass.pin.cap;
6220 wcap = w->param.widget_cap;
6221
6222 device_printf(sc->dev, " Pin cap: 0x%08x\n", pincap);
6223 device_printf(sc->dev, " ");
6224 if (HDA_PARAM_PIN_CAP_IMP_SENSE_CAP(pincap))
6225 printf(" ISC");
6226 if (HDA_PARAM_PIN_CAP_TRIGGER_REQD(pincap))
6227 printf(" TRQD");
6228 if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(pincap))

--- 17 unchanged lines hidden (view full) ---

6246 if (HDA_PARAM_PIN_CAP_VREF_CTRL_GROUND(pincap))
6247 printf(" GROUND");
6248 if (HDA_PARAM_PIN_CAP_VREF_CTRL_HIZ(pincap))
6249 printf(" HIZ");
6250 printf(" ]");
6251 }
6252 if (HDA_PARAM_PIN_CAP_EAPD_CAP(pincap))
6253 printf(" EAPD");
6230
6231 device_printf(sc->dev, " Pin cap: 0x%08x\n", pincap);
6232 device_printf(sc->dev, " ");
6233 if (HDA_PARAM_PIN_CAP_IMP_SENSE_CAP(pincap))
6234 printf(" ISC");
6235 if (HDA_PARAM_PIN_CAP_TRIGGER_REQD(pincap))
6236 printf(" TRQD");
6237 if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(pincap))

--- 17 unchanged lines hidden (view full) ---

6255 if (HDA_PARAM_PIN_CAP_VREF_CTRL_GROUND(pincap))
6256 printf(" GROUND");
6257 if (HDA_PARAM_PIN_CAP_VREF_CTRL_HIZ(pincap))
6258 printf(" HIZ");
6259 printf(" ]");
6260 }
6261 if (HDA_PARAM_PIN_CAP_EAPD_CAP(pincap))
6262 printf(" EAPD");
6254 if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(wcap))
6255 printf(" : UNSOL");
6256 printf("\n");
6257 device_printf(sc->dev, " Pin config: 0x%08x\n",
6258 w->wclass.pin.config);
6259 device_printf(sc->dev, " Pin control: 0x%08x", w->wclass.pin.ctrl);
6260 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE)
6261 printf(" HP");
6262 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE)
6263 printf(" IN");

--- 4 unchanged lines hidden (view full) ---

6268 printf("\n");
6269}
6270
6271static void
6272hdac_dump_pin_config(struct hdac_widget *w, uint32_t conf)
6273{
6274 struct hdac_softc *sc = w->devinfo->codec->sc;
6275
6263 printf("\n");
6264 device_printf(sc->dev, " Pin config: 0x%08x\n",
6265 w->wclass.pin.config);
6266 device_printf(sc->dev, " Pin control: 0x%08x", w->wclass.pin.ctrl);
6267 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE)
6268 printf(" HP");
6269 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE)
6270 printf(" IN");

--- 4 unchanged lines hidden (view full) ---

6275 printf("\n");
6276}
6277
6278static void
6279hdac_dump_pin_config(struct hdac_widget *w, uint32_t conf)
6280{
6281 struct hdac_softc *sc = w->devinfo->codec->sc;
6282
6276 device_printf(sc->dev, "nid %d 0x%08x as %2d seq %2d %13s %5s "
6283 device_printf(sc->dev, " nid %d 0x%08x as %2d seq %2d %13s %5s "
6277 "jack %2d loc %2d color %7s misc %d%s\n",
6278 w->nid, conf,
6279 HDA_CONFIG_DEFAULTCONF_ASSOCIATION(conf),
6280 HDA_CONFIG_DEFAULTCONF_SEQUENCE(conf),
6281 HDA_DEVS[HDA_CONFIG_DEFAULTCONF_DEVICE(conf)],
6282 HDA_CONNS[HDA_CONFIG_DEFAULTCONF_CONNECTIVITY(conf)],
6283 HDA_CONFIG_DEFAULTCONF_CONNECTION_TYPE(conf),
6284 HDA_CONFIG_DEFAULTCONF_LOCATION(conf),

--- 51 unchanged lines hidden (view full) ---

6336 devinfo->function.audio.outamp_cap);
6337 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
6338 w = hdac_widget_get(devinfo, i);
6339 if (w == NULL) {
6340 device_printf(sc->dev, "Ghost widget nid=%d\n", i);
6341 continue;
6342 }
6343 device_printf(sc->dev, "\n");
6284 "jack %2d loc %2d color %7s misc %d%s\n",
6285 w->nid, conf,
6286 HDA_CONFIG_DEFAULTCONF_ASSOCIATION(conf),
6287 HDA_CONFIG_DEFAULTCONF_SEQUENCE(conf),
6288 HDA_DEVS[HDA_CONFIG_DEFAULTCONF_DEVICE(conf)],
6289 HDA_CONNS[HDA_CONFIG_DEFAULTCONF_CONNECTIVITY(conf)],
6290 HDA_CONFIG_DEFAULTCONF_CONNECTION_TYPE(conf),
6291 HDA_CONFIG_DEFAULTCONF_LOCATION(conf),

--- 51 unchanged lines hidden (view full) ---

6343 devinfo->function.audio.outamp_cap);
6344 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
6345 w = hdac_widget_get(devinfo, i);
6346 if (w == NULL) {
6347 device_printf(sc->dev, "Ghost widget nid=%d\n", i);
6348 continue;
6349 }
6350 device_printf(sc->dev, "\n");
6344 device_printf(sc->dev, " nid: %d [%s]%s\n", w->nid,
6345 HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap) ?
6346 "DIGITAL" : "ANALOG",
6351 device_printf(sc->dev, " nid: %d%s\n", w->nid,
6347 (w->enable == 0) ? " [DISABLED]" : "");
6352 (w->enable == 0) ? " [DISABLED]" : "");
6348 device_printf(sc->dev, " name: %s\n", w->name);
6349 device_printf(sc->dev, " widget_cap: 0x%08x\n",
6353 device_printf(sc->dev, " Name: %s\n", w->name);
6354 device_printf(sc->dev, " Widget cap: 0x%08x\n",
6350 w->param.widget_cap);
6355 w->param.widget_cap);
6351 device_printf(sc->dev, " Parse flags: 0x%x\n",
6352 w->pflags);
6353 device_printf(sc->dev, " Association: %d (0x%08x)\n",
6354 w->bindas, w->bindseqmask);
6355 device_printf(sc->dev, " OSS: %s",
6356 hdac_audio_ctl_ossmixer_mask2allname(w->ossmask, buf, sizeof(buf)));
6357 if (w->ossdev >= 0)
6358 printf(" (%s)", ossname[w->ossdev]);
6359 printf("\n");
6356 if (w->param.widget_cap & 0x0ee1) {
6357 device_printf(sc->dev, " ");
6358 if (HDA_PARAM_AUDIO_WIDGET_CAP_LR_SWAP(w->param.widget_cap))
6359 printf(" LRSWAP");
6360 if (HDA_PARAM_AUDIO_WIDGET_CAP_POWER_CTRL(w->param.widget_cap))
6361 printf(" PWR");
6362 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap))
6363 printf(" DIGITAL");
6364 if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(w->param.widget_cap))
6365 printf(" UNSOL");
6366 if (HDA_PARAM_AUDIO_WIDGET_CAP_PROC_WIDGET(w->param.widget_cap))
6367 printf(" PROC");
6368 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap))
6369 printf(" STRIPE");
6370 if (HDA_PARAM_AUDIO_WIDGET_CAP_STEREO(w->param.widget_cap))
6371 printf(" STEREO");
6372 printf("\n");
6373 }
6374 if (w->bindas != -1) {
6375 device_printf(sc->dev, " Association: %d (0x%08x)\n",
6376 w->bindas, w->bindseqmask);
6377 }
6378 if (w->ossmask != 0 || w->ossdev >= 0) {
6379 device_printf(sc->dev, " OSS: %s",
6380 hdac_audio_ctl_ossmixer_mask2allname(w->ossmask, buf, sizeof(buf)));
6381 if (w->ossdev >= 0)
6382 printf(" (%s)", ossname[w->ossdev]);
6383 printf("\n");
6384 }
6360 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT ||
6361 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
6362 hdac_dump_audio_formats(sc->dev,
6363 w->param.supp_stream_formats,
6364 w->param.supp_pcm_size_rate);
6365 } else if (w->type ==
6366 HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
6367 hdac_dump_pin(sc, w);
6368 if (w->param.eapdbtl != HDAC_INVALID)
6369 device_printf(sc->dev, " EAPD: 0x%08x\n",
6370 w->param.eapdbtl);
6371 if (HDA_PARAM_AUDIO_WIDGET_CAP_OUT_AMP(w->param.widget_cap) &&
6372 w->param.outamp_cap != 0)
6373 hdac_dump_amp(sc, w->param.outamp_cap, "Output");
6374 if (HDA_PARAM_AUDIO_WIDGET_CAP_IN_AMP(w->param.widget_cap) &&
6375 w->param.inamp_cap != 0)
6376 hdac_dump_amp(sc, w->param.inamp_cap, " Input");
6385 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT ||
6386 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
6387 hdac_dump_audio_formats(sc->dev,
6388 w->param.supp_stream_formats,
6389 w->param.supp_pcm_size_rate);
6390 } else if (w->type ==
6391 HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
6392 hdac_dump_pin(sc, w);
6393 if (w->param.eapdbtl != HDAC_INVALID)
6394 device_printf(sc->dev, " EAPD: 0x%08x\n",
6395 w->param.eapdbtl);
6396 if (HDA_PARAM_AUDIO_WIDGET_CAP_OUT_AMP(w->param.widget_cap) &&
6397 w->param.outamp_cap != 0)
6398 hdac_dump_amp(sc, w->param.outamp_cap, "Output");
6399 if (HDA_PARAM_AUDIO_WIDGET_CAP_IN_AMP(w->param.widget_cap) &&
6400 w->param.inamp_cap != 0)
6401 hdac_dump_amp(sc, w->param.inamp_cap, " Input");
6377 device_printf(sc->dev, " connections: %d\n", w->nconns);
6378 if (w->nconns > 0)
6402 if (w->nconns > 0) {
6403 device_printf(sc->dev, " connections: %d\n", w->nconns);
6379 device_printf(sc->dev, " |\n");
6404 device_printf(sc->dev, " |\n");
6405 }
6380 for (j = 0; j < w->nconns; j++) {
6381 cw = hdac_widget_get(devinfo, w->conns[j]);
6382 device_printf(sc->dev, " + %s<- nid=%d [%s]",
6383 (w->connsenable[j] == 0)?"[DISABLED] ":"",
6384 w->conns[j], (cw == NULL) ? "GHOST!" : cw->name);
6385 if (cw == NULL)
6386 printf(" [UNKNOWN]");
6387 else if (cw->enable == 0)

--- 536 unchanged lines hidden (view full) ---

6924 int codec_index, fg_index;
6925 int i, pdev, rdev, dmaalloc = 0;
6926 struct hdac_devinfo *devinfo;
6927
6928 sc = (struct hdac_softc *)arg;
6929
6930 hdac_config_fetch(sc, &quirks_on, &quirks_off);
6931
6406 for (j = 0; j < w->nconns; j++) {
6407 cw = hdac_widget_get(devinfo, w->conns[j]);
6408 device_printf(sc->dev, " + %s<- nid=%d [%s]",
6409 (w->connsenable[j] == 0)?"[DISABLED] ":"",
6410 w->conns[j], (cw == NULL) ? "GHOST!" : cw->name);
6411 if (cw == NULL)
6412 printf(" [UNKNOWN]");
6413 else if (cw->enable == 0)

--- 536 unchanged lines hidden (view full) ---

6950 int codec_index, fg_index;
6951 int i, pdev, rdev, dmaalloc = 0;
6952 struct hdac_devinfo *devinfo;
6953
6954 sc = (struct hdac_softc *)arg;
6955
6956 hdac_config_fetch(sc, &quirks_on, &quirks_off);
6957
6932 HDA_BOOTVERBOSE(
6958 HDA_BOOTHVERBOSE(
6933 device_printf(sc->dev, "HDA Config: on=0x%08x off=0x%08x\n",
6934 quirks_on, quirks_off);
6935 );
6936
6937 hdac_lock(sc);
6938
6939 /* Remove ourselves from the config hooks */
6940 if (sc->intrhook.ich_func != NULL) {
6941 config_intrhook_disestablish(&sc->intrhook);
6942 sc->intrhook.ich_func = NULL;
6943 }
6944
6945 /* Start the corb and rirb engines */
6959 device_printf(sc->dev, "HDA Config: on=0x%08x off=0x%08x\n",
6960 quirks_on, quirks_off);
6961 );
6962
6963 hdac_lock(sc);
6964
6965 /* Remove ourselves from the config hooks */
6966 if (sc->intrhook.ich_func != NULL) {
6967 config_intrhook_disestablish(&sc->intrhook);
6968 sc->intrhook.ich_func = NULL;
6969 }
6970
6971 /* Start the corb and rirb engines */
6946 HDA_BOOTVERBOSE(
6972 HDA_BOOTHVERBOSE(
6947 device_printf(sc->dev, "Starting CORB Engine...\n");
6948 );
6949 hdac_corb_start(sc);
6973 device_printf(sc->dev, "Starting CORB Engine...\n");
6974 );
6975 hdac_corb_start(sc);
6950 HDA_BOOTVERBOSE(
6976 HDA_BOOTHVERBOSE(
6951 device_printf(sc->dev, "Starting RIRB Engine...\n");
6952 );
6953 hdac_rirb_start(sc);
6954
6977 device_printf(sc->dev, "Starting RIRB Engine...\n");
6978 );
6979 hdac_rirb_start(sc);
6980
6955 HDA_BOOTVERBOSE(
6981 HDA_BOOTHVERBOSE(
6956 device_printf(sc->dev,
6957 "Enabling controller interrupt...\n");
6958 );
6959 HDAC_WRITE_4(&sc->mem, HDAC_GCTL, HDAC_READ_4(&sc->mem, HDAC_GCTL) |
6960 HDAC_GCTL_UNSOL);
6961 if (sc->polling == 0) {
6962 HDAC_WRITE_4(&sc->mem, HDAC_INTCTL,
6963 HDAC_INTCTL_CIE | HDAC_INTCTL_GIE);
6964 } else {
6965 callout_reset(&sc->poll_hdac, 1, hdac_poll_callback, sc);
6966 }
6967 DELAY(1000);
6968
6982 device_printf(sc->dev,
6983 "Enabling controller interrupt...\n");
6984 );
6985 HDAC_WRITE_4(&sc->mem, HDAC_GCTL, HDAC_READ_4(&sc->mem, HDAC_GCTL) |
6986 HDAC_GCTL_UNSOL);
6987 if (sc->polling == 0) {
6988 HDAC_WRITE_4(&sc->mem, HDAC_INTCTL,
6989 HDAC_INTCTL_CIE | HDAC_INTCTL_GIE);
6990 } else {
6991 callout_reset(&sc->poll_hdac, 1, hdac_poll_callback, sc);
6992 }
6993 DELAY(1000);
6994
6969 HDA_BOOTVERBOSE(
6995 HDA_BOOTHVERBOSE(
6970 device_printf(sc->dev,
6971 "Scanning HDA codecs ...\n");
6972 );
6973 hdac_scan_codecs(sc);
6974
6975 for (codec_index = 0; codec_index < HDAC_CODEC_MAX; codec_index++) {
6976 codec = sc->codecs[codec_index];
6977 if (codec == NULL)
6978 continue;
6979 for (fg_index = 0; fg_index < codec->num_fgs; fg_index++) {
6980 devinfo = &codec->fgs[fg_index];
6981 HDA_BOOTVERBOSE(
6982 device_printf(sc->dev, "\n");
6996 device_printf(sc->dev,
6997 "Scanning HDA codecs ...\n");
6998 );
6999 hdac_scan_codecs(sc);
7000
7001 for (codec_index = 0; codec_index < HDAC_CODEC_MAX; codec_index++) {
7002 codec = sc->codecs[codec_index];
7003 if (codec == NULL)
7004 continue;
7005 for (fg_index = 0; fg_index < codec->num_fgs; fg_index++) {
7006 devinfo = &codec->fgs[fg_index];
7007 HDA_BOOTVERBOSE(
7008 device_printf(sc->dev, "\n");
7009 device_printf(sc->dev,
7010 "Processing %s FG cad=%d nid=%d...\n",
7011 (devinfo->node_type == HDA_PARAM_FCT_GRP_TYPE_NODE_TYPE_AUDIO) ? "audio":
7012 (devinfo->node_type == HDA_PARAM_FCT_GRP_TYPE_NODE_TYPE_MODEM) ? "modem":
7013 "unknown",
7014 devinfo->codec->cad, devinfo->nid);
6983 );
6984 if (devinfo->node_type !=
6985 HDA_PARAM_FCT_GRP_TYPE_NODE_TYPE_AUDIO) {
7015 );
7016 if (devinfo->node_type !=
7017 HDA_PARAM_FCT_GRP_TYPE_NODE_TYPE_AUDIO) {
6986 HDA_BOOTVERBOSE(
7018 HDA_BOOTHVERBOSE(
6987 device_printf(sc->dev,
7019 device_printf(sc->dev,
6988 "Power down unsupported non-audio FG"
6989 " cad=%d nid=%d to the D3 state...\n",
6990 codec->cad, devinfo->nid);
7020 "Powering down...\n");
6991 );
6992 hdac_command(sc,
6993 HDA_CMD_SET_POWER_STATE(codec->cad,
6994 devinfo->nid, HDA_CMD_POWER_STATE_D3),
6995 codec->cad);
6996 continue;
6997 }
6998
7021 );
7022 hdac_command(sc,
7023 HDA_CMD_SET_POWER_STATE(codec->cad,
7024 devinfo->nid, HDA_CMD_POWER_STATE_D3),
7025 codec->cad);
7026 continue;
7027 }
7028
6999 HDA_BOOTVERBOSE(
7000 device_printf(sc->dev,
7001 "Power up audio FG cad=%d nid=%d...\n",
7002 devinfo->codec->cad, devinfo->nid);
7029 HDA_BOOTHVERBOSE(
7030 device_printf(sc->dev, "Powering up...\n");
7003 );
7004 hdac_powerup(devinfo);
7031 );
7032 hdac_powerup(devinfo);
7005 HDA_BOOTVERBOSE(
7033 HDA_BOOTHVERBOSE(
7006 device_printf(sc->dev, "Parsing audio FG...\n");
7007 );
7008 hdac_audio_parse(devinfo);
7034 device_printf(sc->dev, "Parsing audio FG...\n");
7035 );
7036 hdac_audio_parse(devinfo);
7009 HDA_BOOTVERBOSE(
7037 HDA_BOOTHVERBOSE(
7010 device_printf(sc->dev, "Parsing Ctls...\n");
7011 );
7012 hdac_audio_ctl_parse(devinfo);
7038 device_printf(sc->dev, "Parsing Ctls...\n");
7039 );
7040 hdac_audio_ctl_parse(devinfo);
7013 HDA_BOOTVERBOSE(
7041 HDA_BOOTHVERBOSE(
7014 device_printf(sc->dev, "Parsing vendor patch...\n");
7015 );
7016 hdac_vendor_patch_parse(devinfo);
7017 devinfo->function.audio.quirks |= quirks_on;
7018 devinfo->function.audio.quirks &= ~quirks_off;
7019
7042 device_printf(sc->dev, "Parsing vendor patch...\n");
7043 );
7044 hdac_vendor_patch_parse(devinfo);
7045 devinfo->function.audio.quirks |= quirks_on;
7046 devinfo->function.audio.quirks &= ~quirks_off;
7047
7020 HDA_BOOTVERBOSE(
7048 HDA_BOOTHVERBOSE(
7021 device_printf(sc->dev, "Disabling nonaudio...\n");
7022 );
7023 hdac_audio_disable_nonaudio(devinfo);
7049 device_printf(sc->dev, "Disabling nonaudio...\n");
7050 );
7051 hdac_audio_disable_nonaudio(devinfo);
7024 HDA_BOOTVERBOSE(
7052 HDA_BOOTHVERBOSE(
7025 device_printf(sc->dev, "Disabling useless...\n");
7026 );
7027 hdac_audio_disable_useless(devinfo);
7028 HDA_BOOTVERBOSE(
7029 device_printf(sc->dev, "Patched pins configuration:\n");
7030 hdac_dump_pin_configs(devinfo);
7053 device_printf(sc->dev, "Disabling useless...\n");
7054 );
7055 hdac_audio_disable_useless(devinfo);
7056 HDA_BOOTVERBOSE(
7057 device_printf(sc->dev, "Patched pins configuration:\n");
7058 hdac_dump_pin_configs(devinfo);
7059 );
7060 HDA_BOOTHVERBOSE(
7031 device_printf(sc->dev, "Parsing pin associations...\n");
7032 );
7033 hdac_audio_as_parse(devinfo);
7061 device_printf(sc->dev, "Parsing pin associations...\n");
7062 );
7063 hdac_audio_as_parse(devinfo);
7034 HDA_BOOTVERBOSE(
7064 HDA_BOOTHVERBOSE(
7035 device_printf(sc->dev, "Building AFG tree...\n");
7036 );
7037 hdac_audio_build_tree(devinfo);
7065 device_printf(sc->dev, "Building AFG tree...\n");
7066 );
7067 hdac_audio_build_tree(devinfo);
7038 HDA_BOOTVERBOSE(
7068 HDA_BOOTHVERBOSE(
7039 device_printf(sc->dev, "Disabling unassociated "
7040 "widgets...\n");
7041 );
7042 hdac_audio_disable_unas(devinfo);
7069 device_printf(sc->dev, "Disabling unassociated "
7070 "widgets...\n");
7071 );
7072 hdac_audio_disable_unas(devinfo);
7043 HDA_BOOTVERBOSE(
7073 HDA_BOOTHVERBOSE(
7044 device_printf(sc->dev, "Disabling nonselected "
7045 "inputs...\n");
7046 );
7047 hdac_audio_disable_notselected(devinfo);
7074 device_printf(sc->dev, "Disabling nonselected "
7075 "inputs...\n");
7076 );
7077 hdac_audio_disable_notselected(devinfo);
7048 HDA_BOOTVERBOSE(
7078 HDA_BOOTHVERBOSE(
7049 device_printf(sc->dev, "Disabling useless...\n");
7050 );
7051 hdac_audio_disable_useless(devinfo);
7079 device_printf(sc->dev, "Disabling useless...\n");
7080 );
7081 hdac_audio_disable_useless(devinfo);
7052 HDA_BOOTVERBOSE(
7082 HDA_BOOTHVERBOSE(
7053 device_printf(sc->dev, "Disabling "
7054 "crossassociatement connections...\n");
7055 );
7056 hdac_audio_disable_crossas(devinfo);
7083 device_printf(sc->dev, "Disabling "
7084 "crossassociatement connections...\n");
7085 );
7086 hdac_audio_disable_crossas(devinfo);
7057 HDA_BOOTVERBOSE(
7087 HDA_BOOTHVERBOSE(
7058 device_printf(sc->dev, "Disabling useless...\n");
7059 );
7060 hdac_audio_disable_useless(devinfo);
7088 device_printf(sc->dev, "Disabling useless...\n");
7089 );
7090 hdac_audio_disable_useless(devinfo);
7061 HDA_BOOTVERBOSE(
7091 HDA_BOOTHVERBOSE(
7062 device_printf(sc->dev, "Binding associations to channels...\n");
7063 );
7064 hdac_audio_bind_as(devinfo);
7092 device_printf(sc->dev, "Binding associations to channels...\n");
7093 );
7094 hdac_audio_bind_as(devinfo);
7065 HDA_BOOTVERBOSE(
7095 HDA_BOOTHVERBOSE(
7066 device_printf(sc->dev, "Assigning names to signal sources...\n");
7067 );
7068 hdac_audio_assign_names(devinfo);
7096 device_printf(sc->dev, "Assigning names to signal sources...\n");
7097 );
7098 hdac_audio_assign_names(devinfo);
7069 HDA_BOOTVERBOSE(
7099 HDA_BOOTHVERBOSE(
7070 device_printf(sc->dev, "Assigning mixers to the tree...\n");
7071 );
7072 hdac_audio_assign_mixers(devinfo);
7100 device_printf(sc->dev, "Assigning mixers to the tree...\n");
7101 );
7102 hdac_audio_assign_mixers(devinfo);
7073 HDA_BOOTVERBOSE(
7103 HDA_BOOTHVERBOSE(
7074 device_printf(sc->dev, "Preparing pin controls...\n");
7075 );
7076 hdac_audio_prepare_pin_ctrl(devinfo);
7104 device_printf(sc->dev, "Preparing pin controls...\n");
7105 );
7106 hdac_audio_prepare_pin_ctrl(devinfo);
7077 HDA_BOOTVERBOSE(
7107 HDA_BOOTHVERBOSE(
7078 device_printf(sc->dev, "AFG commit...\n");
7079 );
7080 hdac_audio_commit(devinfo);
7108 device_printf(sc->dev, "AFG commit...\n");
7109 );
7110 hdac_audio_commit(devinfo);
7081 HDA_BOOTVERBOSE(
7111 HDA_BOOTHVERBOSE(
7082 device_printf(sc->dev, "Ctls commit...\n");
7083 );
7084 hdac_audio_ctl_commit(devinfo);
7112 device_printf(sc->dev, "Ctls commit...\n");
7113 );
7114 hdac_audio_ctl_commit(devinfo);
7085 HDA_BOOTVERBOSE(
7115 HDA_BOOTHVERBOSE(
7086 device_printf(sc->dev, "HP switch init...\n");
7087 );
7088 hdac_hp_switch_init(devinfo);
7089
7090 if ((devinfo->function.audio.quirks & HDA_QUIRK_DMAPOS) &&
7091 dmaalloc == 0) {
7092 if (hdac_dma_alloc(sc, &sc->pos_dma,
7093 (sc->num_iss + sc->num_oss + sc->num_bss) * 8) != 0) {

--- 51 unchanged lines hidden (view full) ---

7145 pdevinfo->dev =
7146 device_add_child(sc->dev, "pcm", -1);
7147 device_set_ivars(pdevinfo->dev,
7148 (void *)pdevinfo);
7149 }
7150
7151 HDA_BOOTVERBOSE(
7152 if (devinfo->function.audio.quirks != 0) {
7116 device_printf(sc->dev, "HP switch init...\n");
7117 );
7118 hdac_hp_switch_init(devinfo);
7119
7120 if ((devinfo->function.audio.quirks & HDA_QUIRK_DMAPOS) &&
7121 dmaalloc == 0) {
7122 if (hdac_dma_alloc(sc, &sc->pos_dma,
7123 (sc->num_iss + sc->num_oss + sc->num_bss) * 8) != 0) {

--- 51 unchanged lines hidden (view full) ---

7175 pdevinfo->dev =
7176 device_add_child(sc->dev, "pcm", -1);
7177 device_set_ivars(pdevinfo->dev,
7178 (void *)pdevinfo);
7179 }
7180
7181 HDA_BOOTVERBOSE(
7182 if (devinfo->function.audio.quirks != 0) {
7153 device_printf(sc->dev, "\n");
7154 device_printf(sc->dev, "HDA config/quirks:");
7183 device_printf(sc->dev, "FG config/quirks:");
7155 for (i = 0; i < HDAC_QUIRKS_TAB_LEN; i++) {
7156 if ((devinfo->function.audio.quirks &
7157 hdac_quirks_tab[i].value) ==
7158 hdac_quirks_tab[i].value)
7159 printf(" %s", hdac_quirks_tab[i].key);
7160 }
7161 printf("\n");
7162 }
7163
7164 device_printf(sc->dev, "\n");
7165 device_printf(sc->dev, "+-------------------+\n");
7166 device_printf(sc->dev, "| DUMPING HDA NODES |\n");
7167 device_printf(sc->dev, "+-------------------+\n");
7168 hdac_dump_nodes(devinfo);
7184 for (i = 0; i < HDAC_QUIRKS_TAB_LEN; i++) {
7185 if ((devinfo->function.audio.quirks &
7186 hdac_quirks_tab[i].value) ==
7187 hdac_quirks_tab[i].value)
7188 printf(" %s", hdac_quirks_tab[i].key);
7189 }
7190 printf("\n");
7191 }
7192
7193 device_printf(sc->dev, "\n");
7194 device_printf(sc->dev, "+-------------------+\n");
7195 device_printf(sc->dev, "| DUMPING HDA NODES |\n");
7196 device_printf(sc->dev, "+-------------------+\n");
7197 hdac_dump_nodes(devinfo);
7198 );
7169
7199
7200 HDA_BOOTHVERBOSE(
7170 device_printf(sc->dev, "\n");
7171 device_printf(sc->dev, "+------------------------+\n");
7172 device_printf(sc->dev, "| DUMPING HDA AMPLIFIERS |\n");
7173 device_printf(sc->dev, "+------------------------+\n");
7174 device_printf(sc->dev, "\n");
7175 i = 0;
7176 while ((ctl = hdac_audio_ctl_each(devinfo, &i)) != NULL) {
7177 device_printf(sc->dev, "%3d: nid %3d %s (%s) index %d", i,

--- 49 unchanged lines hidden (view full) ---

7227static int
7228hdac_suspend(device_t dev)
7229{
7230 struct hdac_softc *sc;
7231 struct hdac_codec *codec;
7232 struct hdac_devinfo *devinfo;
7233 int codec_index, fg_index, i;
7234
7201 device_printf(sc->dev, "\n");
7202 device_printf(sc->dev, "+------------------------+\n");
7203 device_printf(sc->dev, "| DUMPING HDA AMPLIFIERS |\n");
7204 device_printf(sc->dev, "+------------------------+\n");
7205 device_printf(sc->dev, "\n");
7206 i = 0;
7207 while ((ctl = hdac_audio_ctl_each(devinfo, &i)) != NULL) {
7208 device_printf(sc->dev, "%3d: nid %3d %s (%s) index %d", i,

--- 49 unchanged lines hidden (view full) ---

7258static int
7259hdac_suspend(device_t dev)
7260{
7261 struct hdac_softc *sc;
7262 struct hdac_codec *codec;
7263 struct hdac_devinfo *devinfo;
7264 int codec_index, fg_index, i;
7265
7235 HDA_BOOTVERBOSE(
7266 HDA_BOOTHVERBOSE(
7236 device_printf(dev, "Suspend...\n");
7237 );
7238
7239 sc = device_get_softc(dev);
7240 hdac_lock(sc);
7241
7267 device_printf(dev, "Suspend...\n");
7268 );
7269
7270 sc = device_get_softc(dev);
7271 hdac_lock(sc);
7272
7242 HDA_BOOTVERBOSE(
7273 HDA_BOOTHVERBOSE(
7243 device_printf(dev, "Stop streams...\n");
7244 );
7245 for (i = 0; i < sc->num_chans; i++) {
7246 if (sc->chans[i].flags & HDAC_CHN_RUNNING) {
7247 sc->chans[i].flags |= HDAC_CHN_SUSPEND;
7248 hdac_channel_stop(sc, &sc->chans[i]);
7249 }
7250 }
7251
7252 for (codec_index = 0; codec_index < HDAC_CODEC_MAX; codec_index++) {
7253 codec = sc->codecs[codec_index];
7254 if (codec == NULL)
7255 continue;
7256 for (fg_index = 0; fg_index < codec->num_fgs; fg_index++) {
7257 devinfo = &codec->fgs[fg_index];
7274 device_printf(dev, "Stop streams...\n");
7275 );
7276 for (i = 0; i < sc->num_chans; i++) {
7277 if (sc->chans[i].flags & HDAC_CHN_RUNNING) {
7278 sc->chans[i].flags |= HDAC_CHN_SUSPEND;
7279 hdac_channel_stop(sc, &sc->chans[i]);
7280 }
7281 }
7282
7283 for (codec_index = 0; codec_index < HDAC_CODEC_MAX; codec_index++) {
7284 codec = sc->codecs[codec_index];
7285 if (codec == NULL)
7286 continue;
7287 for (fg_index = 0; fg_index < codec->num_fgs; fg_index++) {
7288 devinfo = &codec->fgs[fg_index];
7258 HDA_BOOTVERBOSE(
7289 HDA_BOOTHVERBOSE(
7259 device_printf(dev,
7260 "Power down FG"
7261 " cad=%d nid=%d to the D3 state...\n",
7262 codec->cad, devinfo->nid);
7263 );
7264 hdac_command(sc,
7265 HDA_CMD_SET_POWER_STATE(codec->cad,
7266 devinfo->nid, HDA_CMD_POWER_STATE_D3),
7267 codec->cad);
7268 }
7269 }
7270
7290 device_printf(dev,
7291 "Power down FG"
7292 " cad=%d nid=%d to the D3 state...\n",
7293 codec->cad, devinfo->nid);
7294 );
7295 hdac_command(sc,
7296 HDA_CMD_SET_POWER_STATE(codec->cad,
7297 devinfo->nid, HDA_CMD_POWER_STATE_D3),
7298 codec->cad);
7299 }
7300 }
7301
7271 HDA_BOOTVERBOSE(
7302 HDA_BOOTHVERBOSE(
7272 device_printf(dev, "Reset controller...\n");
7273 );
7274 callout_stop(&sc->poll_hda);
7275 callout_stop(&sc->poll_hdac);
7276 callout_stop(&sc->poll_jack);
7277 hdac_reset(sc, 0);
7278 hdac_unlock(sc);
7279 taskqueue_drain(taskqueue_thread, &sc->unsolq_task);
7280 callout_drain(&sc->poll_hda);
7281 callout_drain(&sc->poll_hdac);
7282 callout_drain(&sc->poll_jack);
7283
7303 device_printf(dev, "Reset controller...\n");
7304 );
7305 callout_stop(&sc->poll_hda);
7306 callout_stop(&sc->poll_hdac);
7307 callout_stop(&sc->poll_jack);
7308 hdac_reset(sc, 0);
7309 hdac_unlock(sc);
7310 taskqueue_drain(taskqueue_thread, &sc->unsolq_task);
7311 callout_drain(&sc->poll_hda);
7312 callout_drain(&sc->poll_hdac);
7313 callout_drain(&sc->poll_jack);
7314
7284 HDA_BOOTVERBOSE(
7315 HDA_BOOTHVERBOSE(
7285 device_printf(dev, "Suspend done\n");
7286 );
7287
7288 return (0);
7289}
7290
7291/****************************************************************************
7292 * int hdac_resume(device_t)
7293 *
7294 * Powerup and restore HDA bus and codecs state.
7295 ****************************************************************************/
7296static int
7297hdac_resume(device_t dev)
7298{
7299 struct hdac_softc *sc;
7300 struct hdac_codec *codec;
7301 struct hdac_devinfo *devinfo;
7302 int codec_index, fg_index, i;
7303
7316 device_printf(dev, "Suspend done\n");
7317 );
7318
7319 return (0);
7320}
7321
7322/****************************************************************************
7323 * int hdac_resume(device_t)
7324 *
7325 * Powerup and restore HDA bus and codecs state.
7326 ****************************************************************************/
7327static int
7328hdac_resume(device_t dev)
7329{
7330 struct hdac_softc *sc;
7331 struct hdac_codec *codec;
7332 struct hdac_devinfo *devinfo;
7333 int codec_index, fg_index, i;
7334
7304 HDA_BOOTVERBOSE(
7335 HDA_BOOTHVERBOSE(
7305 device_printf(dev, "Resume...\n");
7306 );
7307
7308 sc = device_get_softc(dev);
7309 hdac_lock(sc);
7310
7311 /* Quiesce everything */
7336 device_printf(dev, "Resume...\n");
7337 );
7338
7339 sc = device_get_softc(dev);
7340 hdac_lock(sc);
7341
7342 /* Quiesce everything */
7312 HDA_BOOTVERBOSE(
7343 HDA_BOOTHVERBOSE(
7313 device_printf(dev, "Reset controller...\n");
7314 );
7315 hdac_reset(sc, 1);
7316
7317 /* Initialize the CORB and RIRB */
7318 hdac_corb_init(sc);
7319 hdac_rirb_init(sc);
7320
7321 /* Start the corb and rirb engines */
7344 device_printf(dev, "Reset controller...\n");
7345 );
7346 hdac_reset(sc, 1);
7347
7348 /* Initialize the CORB and RIRB */
7349 hdac_corb_init(sc);
7350 hdac_rirb_init(sc);
7351
7352 /* Start the corb and rirb engines */
7322 HDA_BOOTVERBOSE(
7353 HDA_BOOTHVERBOSE(
7323 device_printf(dev, "Starting CORB Engine...\n");
7324 );
7325 hdac_corb_start(sc);
7354 device_printf(dev, "Starting CORB Engine...\n");
7355 );
7356 hdac_corb_start(sc);
7326 HDA_BOOTVERBOSE(
7357 HDA_BOOTHVERBOSE(
7327 device_printf(dev, "Starting RIRB Engine...\n");
7328 );
7329 hdac_rirb_start(sc);
7330
7358 device_printf(dev, "Starting RIRB Engine...\n");
7359 );
7360 hdac_rirb_start(sc);
7361
7331 HDA_BOOTVERBOSE(
7362 HDA_BOOTHVERBOSE(
7332 device_printf(dev,
7333 "Enabling controller interrupt...\n");
7334 );
7335 HDAC_WRITE_4(&sc->mem, HDAC_GCTL, HDAC_READ_4(&sc->mem, HDAC_GCTL) |
7336 HDAC_GCTL_UNSOL);
7337 if (sc->polling == 0) {
7338 HDAC_WRITE_4(&sc->mem, HDAC_INTCTL,
7339 HDAC_INTCTL_CIE | HDAC_INTCTL_GIE);

--- 5 unchanged lines hidden (view full) ---

7345 for (codec_index = 0; codec_index < HDAC_CODEC_MAX; codec_index++) {
7346 codec = sc->codecs[codec_index];
7347 if (codec == NULL)
7348 continue;
7349 for (fg_index = 0; fg_index < codec->num_fgs; fg_index++) {
7350 devinfo = &codec->fgs[fg_index];
7351 if (devinfo->node_type !=
7352 HDA_PARAM_FCT_GRP_TYPE_NODE_TYPE_AUDIO) {
7363 device_printf(dev,
7364 "Enabling controller interrupt...\n");
7365 );
7366 HDAC_WRITE_4(&sc->mem, HDAC_GCTL, HDAC_READ_4(&sc->mem, HDAC_GCTL) |
7367 HDAC_GCTL_UNSOL);
7368 if (sc->polling == 0) {
7369 HDAC_WRITE_4(&sc->mem, HDAC_INTCTL,
7370 HDAC_INTCTL_CIE | HDAC_INTCTL_GIE);

--- 5 unchanged lines hidden (view full) ---

7376 for (codec_index = 0; codec_index < HDAC_CODEC_MAX; codec_index++) {
7377 codec = sc->codecs[codec_index];
7378 if (codec == NULL)
7379 continue;
7380 for (fg_index = 0; fg_index < codec->num_fgs; fg_index++) {
7381 devinfo = &codec->fgs[fg_index];
7382 if (devinfo->node_type !=
7383 HDA_PARAM_FCT_GRP_TYPE_NODE_TYPE_AUDIO) {
7353 HDA_BOOTVERBOSE(
7384 HDA_BOOTHVERBOSE(
7354 device_printf(dev,
7355 "Power down unsupported non-audio FG"
7356 " cad=%d nid=%d to the D3 state...\n",
7357 codec->cad, devinfo->nid);
7358 );
7359 hdac_command(sc,
7360 HDA_CMD_SET_POWER_STATE(codec->cad,
7361 devinfo->nid, HDA_CMD_POWER_STATE_D3),
7362 codec->cad);
7363 continue;
7364 }
7365
7385 device_printf(dev,
7386 "Power down unsupported non-audio FG"
7387 " cad=%d nid=%d to the D3 state...\n",
7388 codec->cad, devinfo->nid);
7389 );
7390 hdac_command(sc,
7391 HDA_CMD_SET_POWER_STATE(codec->cad,
7392 devinfo->nid, HDA_CMD_POWER_STATE_D3),
7393 codec->cad);
7394 continue;
7395 }
7396
7366 HDA_BOOTVERBOSE(
7397 HDA_BOOTHVERBOSE(
7367 device_printf(dev,
7368 "Power up audio FG cad=%d nid=%d...\n",
7369 devinfo->codec->cad, devinfo->nid);
7370 );
7371 hdac_powerup(devinfo);
7398 device_printf(dev,
7399 "Power up audio FG cad=%d nid=%d...\n",
7400 devinfo->codec->cad, devinfo->nid);
7401 );
7402 hdac_powerup(devinfo);
7372 HDA_BOOTVERBOSE(
7403 HDA_BOOTHVERBOSE(
7373 device_printf(dev, "AFG commit...\n");
7374 );
7375 hdac_audio_commit(devinfo);
7404 device_printf(dev, "AFG commit...\n");
7405 );
7406 hdac_audio_commit(devinfo);
7376 HDA_BOOTVERBOSE(
7407 HDA_BOOTHVERBOSE(
7377 device_printf(dev, "Ctls commit...\n");
7378 );
7379 hdac_audio_ctl_commit(devinfo);
7408 device_printf(dev, "Ctls commit...\n");
7409 );
7410 hdac_audio_ctl_commit(devinfo);
7380 HDA_BOOTVERBOSE(
7411 HDA_BOOTHVERBOSE(
7381 device_printf(dev, "HP switch init...\n");
7382 );
7383 hdac_hp_switch_init(devinfo);
7384
7385 hdac_unlock(sc);
7386 for (i = 0; i < devinfo->function.audio.num_devs; i++) {
7387 struct hdac_pcm_devinfo *pdevinfo =
7388 &devinfo->function.audio.devs[i];
7412 device_printf(dev, "HP switch init...\n");
7413 );
7414 hdac_hp_switch_init(devinfo);
7415
7416 hdac_unlock(sc);
7417 for (i = 0; i < devinfo->function.audio.num_devs; i++) {
7418 struct hdac_pcm_devinfo *pdevinfo =
7419 &devinfo->function.audio.devs[i];
7389 HDA_BOOTVERBOSE(
7420 HDA_BOOTHVERBOSE(
7390 device_printf(pdevinfo->dev,
7391 "OSS mixer reinitialization...\n");
7392 );
7393 if (mixer_reinit(pdevinfo->dev) == -1)
7394 device_printf(pdevinfo->dev,
7395 "unable to reinitialize the mixer\n");
7396 }
7397 hdac_lock(sc);
7398 }
7399 }
7400
7421 device_printf(pdevinfo->dev,
7422 "OSS mixer reinitialization...\n");
7423 );
7424 if (mixer_reinit(pdevinfo->dev) == -1)
7425 device_printf(pdevinfo->dev,
7426 "unable to reinitialize the mixer\n");
7427 }
7428 hdac_lock(sc);
7429 }
7430 }
7431
7401 HDA_BOOTVERBOSE(
7432 HDA_BOOTHVERBOSE(
7402 device_printf(dev, "Start streams...\n");
7403 );
7404 for (i = 0; i < sc->num_chans; i++) {
7405 if (sc->chans[i].flags & HDAC_CHN_SUSPEND) {
7406 sc->chans[i].flags &= ~HDAC_CHN_SUSPEND;
7407 hdac_channel_start(sc, &sc->chans[i]);
7408 }
7409 }
7410
7411 hdac_unlock(sc);
7412
7433 device_printf(dev, "Start streams...\n");
7434 );
7435 for (i = 0; i < sc->num_chans; i++) {
7436 if (sc->chans[i].flags & HDAC_CHN_SUSPEND) {
7437 sc->chans[i].flags &= ~HDAC_CHN_SUSPEND;
7438 hdac_channel_start(sc, &sc->chans[i]);
7439 }
7440 }
7441
7442 hdac_unlock(sc);
7443
7413 HDA_BOOTVERBOSE(
7444 HDA_BOOTHVERBOSE(
7414 device_printf(dev, "Resume done\n");
7415 );
7416
7417 return (0);
7418}
7419/****************************************************************************
7420 * int hdac_detach(device_t)
7421 *

--- 115 unchanged lines hidden (view full) ---

7537 pdevinfo->chan_blkcnt = HDA_BDL_DEFAULT;
7538
7539 /*
7540 * We don't register interrupt handler with snd_setup_intr
7541 * in pcm device. Mark pcm device as MPSAFE manually.
7542 */
7543 pcm_setflags(dev, pcm_getflags(dev) | SD_F_MPSAFE);
7544
7445 device_printf(dev, "Resume done\n");
7446 );
7447
7448 return (0);
7449}
7450/****************************************************************************
7451 * int hdac_detach(device_t)
7452 *

--- 115 unchanged lines hidden (view full) ---

7568 pdevinfo->chan_blkcnt = HDA_BDL_DEFAULT;
7569
7570 /*
7571 * We don't register interrupt handler with snd_setup_intr
7572 * in pcm device. Mark pcm device as MPSAFE manually.
7573 */
7574 pcm_setflags(dev, pcm_getflags(dev) | SD_F_MPSAFE);
7575
7545 HDA_BOOTVERBOSE(
7576 HDA_BOOTHVERBOSE(
7546 device_printf(dev, "OSS mixer initialization...\n");
7547 );
7548 if (mixer_init(dev, &hdac_audio_ctl_ossmixer_class, pdevinfo) != 0)
7549 device_printf(dev, "Can't register mixer\n");
7550
7577 device_printf(dev, "OSS mixer initialization...\n");
7578 );
7579 if (mixer_init(dev, &hdac_audio_ctl_ossmixer_class, pdevinfo) != 0)
7580 device_printf(dev, "Can't register mixer\n");
7581
7551 HDA_BOOTVERBOSE(
7582 HDA_BOOTHVERBOSE(
7552 device_printf(dev, "Registering PCM channels...\n");
7553 );
7554 if (pcm_register(dev, pdevinfo, (pdevinfo->play >= 0)?1:0,
7555 (pdevinfo->rec >= 0)?1:0) != 0)
7556 device_printf(dev, "Can't register PCM\n");
7557
7558 pdevinfo->registered++;
7559

--- 45 unchanged lines hidden ---
7583 device_printf(dev, "Registering PCM channels...\n");
7584 );
7585 if (pcm_register(dev, pdevinfo, (pdevinfo->play >= 0)?1:0,
7586 (pdevinfo->rec >= 0)?1:0) != 0)
7587 device_printf(dev, "Can't register PCM\n");
7588
7589 pdevinfo->registered++;
7590

--- 45 unchanged lines hidden ---