Lines Matching +full:beeper +full:- +full:hz

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2008-2012 Alexander Motin <mav@FreeBSD.org>
50 #define hdaa_lock(devinfo) snd_mtxlock((devinfo)->lock)
51 #define hdaa_unlock(devinfo) snd_mtxunlock((devinfo)->lock)
52 #define hdaa_lockassert(devinfo) snd_mtxassert((devinfo)->lock)
82 static const char *HDA_DEVS[16] = {"Line-out", "Speaker", "Headphones", "CD",
83 "SPDIF-out", "Digital-out", "Modem-line", "Modem-handset", "Line-in",
84 "AUX", "Mic", "Telephony", "SPDIF-in", "Digital-in", "Res.E", "Other"};
90 "DIN", "XLR", "RJ-11", "Combo", "0xc", "0xd", "0xe", "Other" };
93 "0x00", "Rear", "Front", "Left", "Right", "Top", "Bottom", "Rear-panel",
94 "Drive-bay", "0x09", "0x0a", "0x0b", "0x0c", "0x0d", "0x0e", "0x0f",
97 "External", "Ext-Rear", "Ext-Front", "Ext-Left", "Ext-Right", "Ext-Top", "Ext-Bottom", "0x07",
99 "Other", "0x31", "0x32", "0x33", "0x34", "0x35", "Other-Bott", "Lid-In",
100 "Lid-Out", "0x39", "0x3a", "0x3b", "0x3c", "0x3d", "0x3e", "0x3f" };
106 "undefined", "LPCM", "AC-3", "MPEG1", "MP3", "MPEG2", "AAC-LC", "DTS",
107 "ATRAC", "DSD", "E-AC-3", "DTS-HD", "MLP", "DST", "WMAPro", "HE-AAC",
108 "HE-AACv2", "MPEG-Surround"
202 index == NULL || devinfo->ctl == NULL ||
203 devinfo->ctlcnt < 1 ||
204 *index < 0 || *index >= devinfo->ctlcnt)
206 return (&devinfo->ctl[(*index)++]);
216 if (devinfo == NULL || devinfo->ctl == NULL)
221 if (ctl->enable == 0)
223 if (ctl->widget->nid != nid)
225 if (dir && ctl->ndir != dir)
227 if (index >= 0 && ctl->ndir == HDAA_CTL_IN &&
228 ctl->dir == ctl->ndir && ctl->index != index)
265 struct hdaa_pcm_devinfo *pdevinfo = as->pdevinfo;
266 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
267 struct hdaa_chan *ch = &devinfo->chans[as->chans[0]];
277 if (as->pins[i] <= 0)
279 w = hdaa_widget_get(devinfo, as->pins[i]);
282 if (w->wclass.pin.connected == 1)
284 else if (w->wclass.pin.connected != 0)
286 if (w->eld != NULL && w->eld_len >= 8)
287 eld = w->eld;
290 if (as->hpredir >= 0)
293 tpins = as->pinset;
317 } else if (as->pinset != 0 && (tpins & 0xffe0) == 0) {
329 if ((as->pinset & 0x0004) == 0)
334 } else if (as->mixed) {
336 if (ch->channels == 1)
343 device_printf(pdevinfo->dev, "%s channel set is: ",
344 as->dir == HDAA_CTL_OUT ? "Playback" : "Recording");
352 if (as->pinset != 0 && matrixes[i].analog == 0)
362 total = ch->channels;
366 device_printf(pdevinfo->dev,
368 as->dir == HDAA_CTL_OUT ? "Playback" : "Recording",
369 assume ? "unknown, assuming " : "", total - sub, sub,
381 struct hdaa_devinfo *devinfo = w->devinfo;
382 struct hdaa_audio_as *as = &devinfo->as[w->bindas];
386 int j, connected = w->wclass.pin.connected;
389 device_printf((as->pdevinfo && as->pdevinfo->dev) ?
390 as->pdevinfo->dev : devinfo->dev,
396 w->nid, HDAA_CTL_IN, -1, 1);
397 if (ctl != NULL && ctl->mute) {
398 /* If pin has muter - use it. */
400 if (val != ctl->forcemute) {
401 ctl->forcemute = val;
407 /* If there is no muter - disable pin output. */
409 val = w->wclass.pin.ctrl |
412 val = w->wclass.pin.ctrl &
414 if (val != w->wclass.pin.ctrl) {
415 w->wclass.pin.ctrl = val;
416 hda_command(devinfo->dev,
418 w->nid, w->wclass.pin.ctrl));
423 if (as->pins[j] <= 0)
426 as->pins[j], HDAA_CTL_IN, -1, 1);
427 if (ctl != NULL && ctl->mute) {
428 /* If pin has muter - use it. */
430 if (val == ctl->forcemute)
432 ctl->forcemute = val;
438 /* If there is no muter - disable pin output. */
439 w1 = hdaa_widget_get(devinfo, as->pins[j]);
442 val = w1->wclass.pin.ctrl &
445 val = w1->wclass.pin.ctrl |
447 if (val != w1->wclass.pin.ctrl) {
448 w1->wclass.pin.ctrl = val;
449 hda_command(devinfo->dev,
451 w1->nid, w1->wclass.pin.ctrl));
463 struct hdaa_pcm_devinfo *pdevinfo = as->pdevinfo;
469 if (!as->mixed || pdevinfo == NULL || pdevinfo->mixer == NULL)
472 if (pdevinfo->autorecsrc == 0 ||
473 (pdevinfo->autorecsrc == 1 && w != NULL))
476 if (pdevinfo->recsrc & (SOUND_MASK_IMIX | SOUND_MASK_SPEAKER))
479 if (ffs(pdevinfo->recsrc) != fls(pdevinfo->recsrc))
481 devinfo = pdevinfo->devinfo;
485 if (as->pins[i] <= 0)
487 w1 = hdaa_widget_get(devinfo, as->pins[i]);
488 if (w1 == NULL || w1->enable == 0)
490 if (w1->wclass.pin.connected == 0)
492 prio = (w1->wclass.pin.connected == 1) ? 2 : 1;
499 mask |= (1 << w1->ossdev);
500 fullmask |= (1 << w1->ossdev);
505 if (w != NULL && (mask & (1 << w->ossdev)))
506 mask = (1 << w->ossdev);
508 if (mask & pdevinfo->recsrc)
509 mask &= pdevinfo->recsrc;
517 mask = (1 << (ffs(mask) - 1));
520 device_printf(pdevinfo->dev,
524 mix_setrecsrc(pdevinfo->mixer, mask);
534 struct hdaa_devinfo *devinfo = w->devinfo;
539 if (w->enable == 0 || w->type !=
543 if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(w->wclass.pin.cap) == 0 ||
544 (HDA_CONFIG_DEFAULTCONF_MISC(w->wclass.pin.config) & 1) != 0)
547 res = hda_command(devinfo->dev, HDA_CMD_GET_PIN_SENSE(0, w->nid));
549 if (devinfo->quirks & HDAA_QUIRK_SENSEINV)
551 old = w->wclass.pin.connected;
554 w->wclass.pin.connected = connected;
557 device_printf(devinfo->dev,
559 w->nid, res, !connected ? "dis" : "");
563 as = &devinfo->as[w->bindas];
564 if (as->hpredir >= 0 && as->pins[15] == w->nid)
566 if (as->dir == HDAA_CTL_IN && old != 2)
583 if (devinfo->poll_ival == 0) {
587 for (i = 0; i < devinfo->ascnt; i++) {
588 if (devinfo->as[i].hpredir < 0)
590 w = hdaa_widget_get(devinfo, devinfo->as[i].pins[15]);
591 if (w == NULL || w->enable == 0 || w->type !=
596 callout_reset(&devinfo->poll_jack, devinfo->poll_ival,
604 struct hdaa_devinfo *devinfo = w->devinfo;
605 device_t dev = devinfo->dev;
609 if (w->eld == NULL || w->eld_len < 4)
613 w->nid, w->eld[0] >> 3, w->eld[2]);
614 if ((w->eld[0] >> 3) != 0x02)
616 mnl = w->eld[4] & 0x1f;
619 w->nid, w->eld[4] >> 5, mnl);
620 sadc = w->eld[5] >> 4;
623 w->nid, sadc, (w->eld[5] >> 2) & 0x3,
624 (w->eld[5] >> 1) & 0x1, w->eld[5] & 0x1);
627 w->nid, w->eld[6] * 2);
630 w->nid, w->eld[7],
634 w->nid, w->eld[8], w->eld[9], w->eld[10], w->eld[11],
635 w->eld[12], w->eld[13], w->eld[14], w->eld[15]);
638 w->nid, w->eld[16], w->eld[17]);
641 w->nid, w->eld[18], w->eld[19]);
644 w->nid, mnl, &w->eld[20]);
646 sad = &w->eld[20 + mnl + i * 3];
657 w->nid, HDA_HDMI_CODING_TYPES[fmt], (sad[0] & 0x07) + 1,
684 struct hdaa_devinfo *devinfo = w->devinfo;
688 if (w->enable == 0 || w->type !=
692 if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(w->wclass.pin.cap) == 0 ||
693 (HDA_CONFIG_DEFAULTCONF_MISC(w->wclass.pin.config) & 1) != 0)
696 res = hda_command(devinfo->dev, HDA_CMD_GET_PIN_SENSE(0, w->nid));
697 if ((w->eld != 0) == ((res & HDA_CMD_GET_PIN_SENSE_ELD_VALID) != 0))
699 if (w->eld != NULL) {
700 w->eld_len = 0;
701 free(w->eld, M_HDAA);
702 w->eld = NULL;
705 device_printf(devinfo->dev,
708 w->nid, res,
715 res = hda_command(devinfo->dev,
716 HDA_CMD_GET_HDMI_DIP_SIZE(0, w->nid, 0x08));
719 w->eld_len = res & 0xff;
720 if (w->eld_len != 0)
721 w->eld = malloc(w->eld_len, M_HDAA, M_ZERO | M_NOWAIT);
722 if (w->eld == NULL) {
723 w->eld_len = 0;
727 for (i = 0; i < w->eld_len; i++) {
728 res = hda_command(devinfo->dev,
729 HDA_CMD_GET_HDMI_ELDD(0, w->nid, i));
731 w->eld[i] = res & 0xff;
736 hdaa_channels_handler(&devinfo->as[w->bindas]);
749 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
751 if (w == NULL || w->enable == 0 || w->type !=
754 if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(w->param.widget_cap)) {
755 if (w->unsol < 0)
756 w->unsol = HDAC_UNSOL_ALLOC(
757 device_get_parent(devinfo->dev),
758 devinfo->dev, w->nid);
759 hda_command(devinfo->dev,
760 HDA_CMD_SET_UNSOLICITED_RESPONSE(0, w->nid,
761 HDA_CMD_SET_UNSOLICITED_RESPONSE_ENABLE | w->unsol));
763 as = &devinfo->as[w->bindas];
764 if (as->hpredir >= 0 && as->pins[15] == w->nid) {
765 if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(w->wclass.pin.cap) == 0 ||
766 (HDA_CONFIG_DEFAULTCONF_MISC(w->wclass.pin.config) & 1) != 0) {
767 device_printf(devinfo->dev,
769 w->nid);
771 if (w->unsol < 0)
774 device_printf(devinfo->dev,
777 w->bindas, w->nid,
778 (w->unsol < 0) ? "polling" :
784 if (!HDA_PARAM_PIN_CAP_DP(w->wclass.pin.cap) &&
785 !HDA_PARAM_PIN_CAP_HDMI(w->wclass.pin.cap))
790 callout_reset(&devinfo->poll_jack, 1,
801 callout_stop(&devinfo->poll_jack);
802 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
804 if (w == NULL || w->enable == 0 || w->type !=
807 if (w->unsol < 0)
809 hda_command(devinfo->dev,
810 HDA_CMD_SET_UNSOLICITED_RESPONSE(0, w->nid, 0));
812 device_get_parent(devinfo->dev), devinfo->dev,
813 w->unsol);
814 w->unsol = -1;
942 device_t dev = w->devinfo->dev;
947 config = orig = w->wclass.pin.config;
949 hda_get_codec_id(dev), w->nid);
960 snprintf(buf, sizeof(buf), "nid%u.config", w->nid);
971 device_printf(w->devinfo->dev,
972 "Patching pin config nid=%u 0x%08x -> 0x%08x\n",
973 w->nid, orig, config);
975 w->wclass.pin.newconf = w->wclass.pin.config = config;
1038 pincap = w->wclass.pin.cap;
1078 conf = w->wclass.pin.config;
1090 sbuf_printf(sb, " Pin control: 0x%08x", w->wclass.pin.ctrl);
1091 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE)
1093 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE)
1095 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_OUT_ENABLE)
1097 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) {
1098 if ((w->wclass.pin.ctrl &
1101 else if ((w->wclass.pin.ctrl &
1105 if ((w->wclass.pin.ctrl &
1125 ((0 - offset) * (size + 1)) / 4,
1126 ((step - offset) * (size + 1)) / 4);
1138 w = (struct hdaa_widget *)oidp->oid_arg1;
1139 devinfo = w->devinfo;
1142 sbuf_printf(&sb, "%s%s\n", w->name,
1143 (w->enable == 0) ? " [DISABLED]" : "");
1145 w->param.widget_cap);
1146 if (w->param.widget_cap & 0x0ee1) {
1147 if (HDA_PARAM_AUDIO_WIDGET_CAP_LR_SWAP(w->param.widget_cap))
1149 if (HDA_PARAM_AUDIO_WIDGET_CAP_POWER_CTRL(w->param.widget_cap))
1151 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap))
1153 if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(w->param.widget_cap))
1155 if (HDA_PARAM_AUDIO_WIDGET_CAP_PROC_WIDGET(w->param.widget_cap))
1157 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap))
1159 1 << (fls(w->wclass.conv.stripecap) - 1));
1160 j = HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap);
1167 if (w->bindas != -1) {
1169 w->bindas, w->bindseqmask);
1171 if (w->ossmask != 0 || w->ossdev >= 0) {
1173 hdaa_audio_ctl_ossmixer_mask2allname(w->ossmask, buf, sizeof(buf)));
1174 if (w->ossdev >= 0)
1175 sbuf_printf(&sb, " (%s)", ossnames[w->ossdev]);
1178 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT ||
1179 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
1181 w->param.supp_stream_formats,
1182 w->param.supp_pcm_size_rate);
1183 } else if (w->type ==
1184 HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || w->waspin)
1186 if (w->param.eapdbtl != HDA_INVALID) {
1188 w->param.eapdbtl,
1189 (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_LR_SWAP) ?
1191 (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD) ?
1193 (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_BTL) ?
1196 if (HDA_PARAM_AUDIO_WIDGET_CAP_OUT_AMP(w->param.widget_cap) &&
1197 w->param.outamp_cap != 0)
1198 hdaa_dump_amp_sb(&sb, w->param.outamp_cap, "Output");
1199 if (HDA_PARAM_AUDIO_WIDGET_CAP_IN_AMP(w->param.widget_cap) &&
1200 w->param.inamp_cap != 0)
1201 hdaa_dump_amp_sb(&sb, w->param.inamp_cap, " Input");
1202 if (w->nconns > 0)
1203 sbuf_printf(&sb, " Connections: %d\n", w->nconns);
1204 for (j = 0; j < w->nconns; j++) {
1205 cw = hdaa_widget_get(devinfo, w->conns[j]);
1206 sbuf_printf(&sb, " + %s<- nid=%d [%s]",
1207 (w->connsenable[j] == 0)?"[DISABLED] ":"",
1208 w->conns[j], (cw == NULL) ? "GHOST!" : cw->name);
1211 else if (cw->enable == 0)
1213 if (w->nconns > 1 && w->selconn == j && w->type !=
1230 conf = *(uint32_t *)oidp->oid_arg1;
1243 if (error != 0 || req->newptr == NULL)
1249 *(uint32_t *)oidp->oid_arg1 = conf;
1269 len = j - i;
1276 hdaa_quirks_tab[k].key, len - inv) != 0)
1278 if (len - inv != strlen(hdaa_quirks_tab[k].key))
1301 quirks = *(uint32_t *)oidp->oid_arg1;
1305 n += snprintf(buf + n, sizeof(buf) - n, "%s%s",
1309 if (error != 0 || req->newptr == NULL)
1317 *(uint32_t *)oidp->oid_arg1 = quirks;
1329 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
1333 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
1337 if (resource_string_value(device_get_name(devinfo->dev),
1338 device_get_unit(devinfo->dev), "config", &res) == 0) {
1341 devinfo->quirks |= quirks_on;
1342 devinfo->quirks &= ~quirks_off;
1344 if (devinfo->newquirks == -1)
1345 devinfo->newquirks = devinfo->quirks;
1347 devinfo->quirks = devinfo->newquirks;
1349 device_printf(devinfo->dev,
1350 "Config options: 0x%08x\n", devinfo->quirks);
1353 if (resource_string_value(device_get_name(devinfo->dev),
1354 device_get_unit(devinfo->dev), "gpio_config", &res) == 0) {
1356 devinfo->gpio = strtol(res + 2, NULL, 16);
1358 devinfo->gpio = hdaa_gpio_patch(devinfo->gpio, res);
1361 if (devinfo->newgpio == -1)
1362 devinfo->newgpio = devinfo->gpio;
1364 devinfo->gpio = devinfo->newgpio;
1365 if (devinfo->newgpo == -1)
1366 devinfo->newgpo = devinfo->gpo;
1368 devinfo->gpo = devinfo->newgpo;
1370 device_printf(devinfo->dev, "GPIO config options:");
1372 x = (devinfo->gpio & HDAA_GPIO_MASK(i)) >> HDAA_GPIO_SHIFT(i);
1385 nid_t nid = w->nid;
1388 w->nconns = 0;
1390 res = hda_command(w->devinfo->dev,
1399 max = (sizeof(w->conns) / sizeof(w->conns[0])) - 1;
1402 #define CONN_RMASK(e) (1 << ((32 / (e)) - 1))
1403 #define CONN_NMASK(e) (CONN_RMASK(e) - 1)
1409 res = hda_command(w->devinfo->dev,
1414 if (w->nconns < ents)
1415 device_printf(w->devinfo->dev,
1420 ents, w->nconns, res);
1424 if (cnid < w->devinfo->startnode ||
1425 cnid >= w->devinfo->endnode) {
1427 device_printf(w->devinfo->dev,
1437 device_printf(w->devinfo->dev,
1447 if (w->nconns > max) {
1448 device_printf(w->devinfo->dev,
1454 w->connsenable[w->nconns] = 1;
1455 w->conns[w->nconns++] = addcnid++;
1468 device_t dev = w->devinfo->dev;
1470 nid_t nid = w->nid;
1473 w->param.widget_cap = wcap = hda_command(dev,
1475 w->type = HDA_PARAM_AUDIO_WIDGET_CAP_TYPE(wcap);
1481 w->param.outamp_cap =
1486 w->param.outamp_cap =
1487 w->devinfo->outamp_cap;
1489 w->param.outamp_cap = 0;
1493 w->param.inamp_cap =
1498 w->param.inamp_cap =
1499 w->devinfo->inamp_cap;
1501 w->param.inamp_cap = 0;
1503 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT ||
1504 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
1509 w->param.supp_stream_formats = (cap != 0) ? cap :
1510 w->devinfo->supp_stream_formats;
1514 w->param.supp_pcm_size_rate = (cap != 0) ? cap :
1515 w->devinfo->supp_pcm_size_rate;
1517 w->param.supp_stream_formats =
1518 w->devinfo->supp_stream_formats;
1519 w->param.supp_pcm_size_rate =
1520 w->devinfo->supp_pcm_size_rate;
1522 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap)) {
1523 w->wclass.conv.stripecap = hda_command(dev,
1524 HDA_CMD_GET_STRIPE_CONTROL(0, w->nid)) >> 20;
1526 w->wclass.conv.stripecap = 1;
1528 w->param.supp_stream_formats = 0;
1529 w->param.supp_pcm_size_rate = 0;
1532 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) {
1533 w->wclass.pin.original = w->wclass.pin.newconf =
1534 w->wclass.pin.config = hda_command(dev,
1535 HDA_CMD_GET_CONFIGURATION_DEFAULT(0, w->nid));
1536 w->wclass.pin.cap = hda_command(dev,
1537 HDA_CMD_GET_PARAMETER(0, w->nid, HDA_PARAM_PIN_CAP));
1538 w->wclass.pin.ctrl = hda_command(dev,
1540 w->wclass.pin.connected = 2;
1541 if (HDA_PARAM_PIN_CAP_EAPD_CAP(w->wclass.pin.cap)) {
1542 w->param.eapdbtl = hda_command(dev,
1544 w->param.eapdbtl &= 0x7;
1545 w->param.eapdbtl |= HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD;
1547 w->param.eapdbtl = HDA_INVALID;
1549 w->unsol = -1;
1551 hdaa_unlock(w->devinfo);
1552 snprintf(buf, sizeof(buf), "nid%d", w->nid);
1557 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) {
1558 snprintf(buf, sizeof(buf), "nid%d_config", w->nid);
1562 &w->wclass.pin.newconf, 0, hdaa_sysctl_config, "A",
1564 snprintf(buf, sizeof(buf), "nid%d_original", w->nid);
1568 &w->wclass.pin.original, 0, hdaa_sysctl_config, "A",
1571 hdaa_lock(w->devinfo);
1579 w->type = HDA_PARAM_AUDIO_WIDGET_CAP_TYPE(w->param.widget_cap);
1580 switch (w->type) {
1612 strlcpy(w->name, typestr, sizeof(w->name));
1614 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) {
1619 config = w->wclass.pin.config;
1626 strlcat(w->name, ": ", sizeof(w->name));
1627 strlcat(w->name, devstr, sizeof(w->name));
1628 strlcat(w->name, " (", sizeof(w->name));
1630 strlcat(w->name, HDA_COLORS[color], sizeof(w->name));
1631 strlcat(w->name, " ", sizeof(w->name));
1633 strlcat(w->name, HDA_CONNS[conn], sizeof(w->name));
1634 strlcat(w->name, ")", sizeof(w->name));
1641 if (devinfo == NULL || devinfo->widget == NULL ||
1642 nid < devinfo->startnode || nid >= devinfo->endnode)
1644 return (&devinfo->widget[nid - devinfo->startnode]);
1655 device_printf(devinfo->dev,
1660 v = (1 << (15 - dir)) | (1 << 13) | (index << 8) |
1662 hda_command(devinfo->dev,
1664 v = (1 << (15 - dir)) | (1 << 12) | (index << 8) |
1667 v = (1 << (15 - dir)) | (3 << 12) | (index << 8) |
1670 hda_command(devinfo->dev,
1681 nid = ctl->widget->nid;
1685 ctl->muted = mute;
1687 ctl->left = left;
1689 ctl->right = right;
1691 if (ctl->forcemute) {
1697 lmute = HDAA_AMP_LEFT_MUTED(ctl->muted);
1698 rmute = HDAA_AMP_RIGHT_MUTED(ctl->muted);
1699 left = ctl->left;
1700 right = ctl->right;
1703 if (ctl->dir & HDAA_CTL_OUT)
1704 hdaa_audio_ctl_amp_set_internal(ctl->widget->devinfo, nid, ctl->index,
1706 if (ctl->dir & HDAA_CTL_IN)
1707 hdaa_audio_ctl_amp_set_internal(ctl->widget->devinfo, nid, ctl->index,
1714 if (w == NULL || w->nconns < 1 || index > (w->nconns - 1))
1717 device_printf(w->devinfo->dev,
1718 "Setting selector nid=%d index=%d\n", w->nid, index);
1720 hda_command(w->devinfo->dev,
1721 HDA_CMD_SET_CONNECTION_SELECT_CONTROL(0, w->nid, index));
1722 w->selconn = index;
1734 struct hdaa_pcm_devinfo *pdevinfo = ch->pdevinfo;
1735 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
1738 if (devinfo->quirks & HDAA_QUIRK_FIXEDRATE) {
1739 ch->caps.minspeed = ch->caps.maxspeed = 48000;
1740 ch->pcmrates[0] = 48000;
1741 ch->pcmrates[1] = 0;
1743 ch->dir = dir;
1744 ch->b = b;
1745 ch->c = c;
1746 ch->blksz = pdevinfo->chan_size / pdevinfo->chan_blkcnt;
1747 ch->blkcnt = pdevinfo->chan_blkcnt;
1750 if (sndbuf_alloc(ch->b, bus_get_dma_tag(devinfo->dev),
1751 hda_get_dma_nocache(devinfo->dev) ? BUS_DMA_NOCACHE :
1753 pdevinfo->chan_size) != 0)
1765 for (i = 0; ch->caps.fmtlist[i] != 0; i++) {
1766 if (format == ch->caps.fmtlist[i]) {
1767 ch->fmt = format;
1783 for (i = 0; ch->pcmrates[i] != 0; i++) {
1784 spd = ch->pcmrates[i];
1786 ch->spd = spd;
1791 for (i = 0; ch->pcmrates[i] != 0; i++) {
1792 spd = ch->pcmrates[i];
1793 threshold = spd + ((ch->pcmrates[i + 1] != 0) ?
1794 ((ch->pcmrates[i + 1] - spd) >> 1) : 0);
1798 ch->spd = spd;
1809 if (ch->fmt & AFMT_S16_LE)
1810 fmt |= ch->bit16 << 4;
1811 else if (ch->fmt & AFMT_S32_LE)
1812 fmt |= ch->bit32 << 4;
1816 if (hda_rate_tab[i].valid && ch->spd == hda_rate_tab[i].rate) {
1823 fmt |= (AFMT_CHANNEL(ch->fmt) - 1);
1837 return (0xffffffffU >> (32 - fls(size / 8)));
1843 struct hdaa_audio_as *as = &ch->devinfo->as[ch->as];
1864 int convmapid = -1;
1868 totalchn = AFMT_CHANNEL(ch->fmt);
1869 totalextchn = AFMT_EXTCHANNEL(ch->fmt);
1871 device_printf(ch->pdevinfo->dev,
1873 (ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC",
1874 ch->fmt, totalchn - totalextchn, totalextchn, ch->spd);
1879 if ((as->pinset == 0x0007 || as->pinset == 0x0013) || /* Standard 5.1 */
1880 (as->pinset == 0x0017)) /* Standard 7.1 */
1881 convmapid = (ch->dir == PCMDIR_PLAY);
1884 if (ch->fmt & AFMT_AC3)
1888 for (i = 0; ch->io[i] != -1; i++) {
1889 w = hdaa_widget_get(ch->devinfo, ch->io[i]);
1895 if (as->fakeredir && i == (as->pincnt - 1)) {
1896 c = (ch->sid << 4);
1901 >> i * 4) & 0xf) - 1) * 2;
1905 c = (ch->sid << 4) | chn;
1908 hda_command(ch->devinfo->dev,
1909 HDA_CMD_SET_CONV_FMT(0, ch->io[i], fmt));
1910 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) {
1911 hda_command(ch->devinfo->dev,
1912 HDA_CMD_SET_DIGITAL_CONV_FMT1(0, ch->io[i], dfmt));
1914 hda_command(ch->devinfo->dev,
1915 HDA_CMD_SET_CONV_STREAM_CHAN(0, ch->io[i], c));
1916 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap)) {
1917 hda_command(ch->devinfo->dev,
1918 HDA_CMD_SET_STRIPE_CONTROL(0, w->nid, ch->stripectl));
1920 cchn = HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap);
1922 cchn = min(cchn, totalchn - chn - 1);
1923 hda_command(ch->devinfo->dev,
1924 HDA_CMD_SET_CONV_CHAN_COUNT(0, ch->io[i], cchn));
1927 device_printf(ch->pdevinfo->dev,
1931 (ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC",
1932 ch->io[i], fmt, dfmt, c, cchn, ch->stripectl);
1935 if (as->dacs[ch->asindex][j] != ch->io[i])
1937 nid = as->pins[j];
1938 wp = hdaa_widget_get(ch->devinfo, nid);
1941 if (!HDA_PARAM_PIN_CAP_DP(wp->wclass.pin.cap) &&
1942 !HDA_PARAM_PIN_CAP_HDMI(wp->wclass.pin.cap))
1947 hda_command(ch->devinfo->dev,
1949 (((hdmich[totalextchn == 0 ? 0 : 1][totalchn - 1]
1957 if (HDA_PARAM_PIN_CAP_HDMI(wp->wclass.pin.cap) &&
1958 HDA_PARAM_PIN_CAP_HBR(wp->wclass.pin.cap)) {
1959 wp->wclass.pin.ctrl &=
1961 if ((ch->fmt & AFMT_AC3) && (cchn == 7))
1962 wp->wclass.pin.ctrl |= 0x03;
1963 hda_command(ch->devinfo->dev,
1965 wp->wclass.pin.ctrl));
1969 hda_command(ch->devinfo->dev,
1971 hda_command(ch->devinfo->dev,
1975 hda_command(ch->devinfo->dev,
1978 hda_command(ch->devinfo->dev,
1982 hda_command(ch->devinfo->dev,
1984 if (w->eld != NULL && w->eld_len >= 6 &&
1985 ((w->eld[5] >> 2) & 0x3) == 1) { /* DisplayPort */
1986 hda_command(ch->devinfo->dev,
1988 hda_command(ch->devinfo->dev,
1990 hda_command(ch->devinfo->dev,
1993 hda_command(ch->devinfo->dev,
1995 hda_command(ch->devinfo->dev,
1997 hda_command(ch->devinfo->dev,
2000 csum -= 0x84 + 0x01 + 0x0a + (totalchn - 1) +
2001 hdmica[totalextchn == 0 ? 0 : 1][totalchn - 1];
2002 hda_command(ch->devinfo->dev,
2005 hda_command(ch->devinfo->dev,
2006 HDA_CMD_SET_HDMI_DIP_DATA(0, nid, totalchn - 1));
2007 hda_command(ch->devinfo->dev,
2009 hda_command(ch->devinfo->dev,
2011 hda_command(ch->devinfo->dev,
2013 hdmica[totalextchn == 0 ? 0 : 1][totalchn - 1]));
2016 hda_command(ch->devinfo->dev,
2018 hda_command(ch->devinfo->dev,
2057 blksz -= blksz % lcm(HDA_DMA_ALIGNMENT, sndbuf_getalign(ch->b));
2059 if (blksz > (sndbuf_getmaxsize(ch->b) / HDA_BDL_MIN))
2060 blksz = sndbuf_getmaxsize(ch->b) / HDA_BDL_MIN;
2068 while ((blksz * blkcnt) > sndbuf_getmaxsize(ch->b)) {
2077 if ((sndbuf_getblksz(ch->b) != blksz ||
2078 sndbuf_getblkcnt(ch->b) != blkcnt) &&
2079 sndbuf_resize(ch->b, blkcnt, blksz) != 0)
2080 device_printf(ch->devinfo->dev, "%s: failed blksz=%u blkcnt=%u\n",
2083 ch->blksz = sndbuf_getblksz(ch->b);
2084 ch->blkcnt = sndbuf_getblkcnt(ch->b);
2094 hdaa_channel_setfragments(obj, data, blksz, ch->pdevinfo->chan_blkcnt);
2096 return (ch->blksz);
2102 struct hdaa_devinfo *devinfo = ch->devinfo;
2106 if ((ch->flags & HDAA_CHN_RUNNING) == 0)
2108 ch->flags &= ~HDAA_CHN_RUNNING;
2109 HDAC_STREAM_STOP(device_get_parent(devinfo->dev), devinfo->dev,
2110 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid);
2111 for (i = 0; ch->io[i] != -1; i++) {
2112 w = hdaa_widget_get(ch->devinfo, ch->io[i]);
2115 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) {
2116 hda_command(devinfo->dev,
2117 HDA_CMD_SET_DIGITAL_CONV_FMT1(0, ch->io[i], 0));
2119 hda_command(devinfo->dev,
2120 HDA_CMD_SET_CONV_STREAM_CHAN(0, ch->io[i],
2123 HDAC_STREAM_FREE(device_get_parent(devinfo->dev), devinfo->dev,
2124 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid);
2130 struct hdaa_devinfo *devinfo = ch->devinfo;
2134 ch->stripectl = fls(ch->stripecap & hdaa_allowed_stripes(fmt) &
2135 hda_get_stripes_mask(devinfo->dev)) - 1;
2136 ch->sid = HDAC_STREAM_ALLOC(device_get_parent(devinfo->dev), devinfo->dev,
2137 ch->dir == PCMDIR_PLAY ? 1 : 0, fmt, ch->stripectl, &ch->dmapos);
2138 if (ch->sid <= 0)
2141 HDAC_STREAM_RESET(device_get_parent(devinfo->dev), devinfo->dev,
2142 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid);
2143 HDAC_STREAM_START(device_get_parent(devinfo->dev), devinfo->dev,
2144 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid,
2145 sndbuf_getbufaddr(ch->b), ch->blksz, ch->blkcnt);
2146 ch->flags |= HDAA_CHN_RUNNING;
2159 hdaa_lock(ch->devinfo);
2171 hdaa_unlock(ch->devinfo);
2180 struct hdaa_devinfo *devinfo = ch->devinfo;
2184 if (ch->dmapos != NULL) {
2185 ptr = *(ch->dmapos);
2188 device_get_parent(devinfo->dev), devinfo->dev,
2189 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid);
2196 ptr %= ch->blksz * ch->blkcnt;
2205 return (&((struct hdaa_chan *)data)->caps);
2225 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
2231 pdevinfo->mixer = m;
2235 pdevinfo->left[i] = 100;
2236 pdevinfo->right[i] = 100;
2240 mask = pdevinfo->ossmask;
2241 if (pdevinfo->playas >= 0) {
2243 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
2245 if (w == NULL || w->enable == 0)
2247 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX ||
2248 w->param.eapdbtl == HDA_INVALID ||
2249 w->bindas != pdevinfo->playas)
2257 (devinfo->quirks & HDAA_QUIRK_SOFTPCMVOL) ||
2258 pdevinfo->minamp[SOUND_MIXER_PCM] ==
2259 pdevinfo->maxamp[SOUND_MIXER_PCM]) {
2261 pcm_setflags(pdevinfo->dev, pcm_getflags(pdevinfo->dev) | SD_F_SOFTPCMVOL);
2263 device_printf(pdevinfo->dev,
2276 device_printf(pdevinfo->dev,
2284 if (pdevinfo->recas >= 0) {
2286 if (devinfo->as[pdevinfo->recas].dacs[0][i] < 0)
2289 devinfo->as[pdevinfo->recas].dacs[0][i]);
2290 if (w == NULL || w->enable == 0)
2292 for (j = 0; j < w->nconns; j++) {
2293 if (w->connsenable[j] == 0)
2295 cw = hdaa_widget_get(devinfo, w->conns[j]);
2296 if (cw == NULL || cw->enable == 0)
2298 if (cw->bindas != pdevinfo->recas &&
2299 cw->bindas != -2)
2301 recmask |= cw->ossmask;
2306 recmask &= (1 << SOUND_MIXER_NRDEVICES) - 1;
2307 mask &= (1 << SOUND_MIXER_NRDEVICES) - 1;
2308 pdevinfo->ossmask = mask;
2328 ctl->devleft[ossdev] = *left;
2329 ctl->devright[ossdev] = *right;
2330 ctl->devmute[ossdev] = mute;
2333 sleft += ctl->devleft[i];
2334 sright += ctl->devright[i];
2335 smute |= ctl->devmute[i];
2338 zleft += ctl->devleft[i];
2339 zright += ctl->devright[i];
2344 *left -= VAL2QDB(ctl, lval) - VAL2QDB(ctl, QDB2VAL(ctl, zleft));
2345 *right -= VAL2QDB(ctl, rval) - VAL2QDB(ctl, QDB2VAL(ctl, zright));
2355 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
2364 if (w == NULL || w->enable == 0)
2369 for (j = 0; j < w->nconns; j++) {
2370 if (!w->connsenable[j])
2376 /* If this is not a first step - use input mixer.
2379 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)) {
2380 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, HDAA_CTL_IN,
2386 /* If widget has own ossdev - not traverse it.
2388 if (w->ossdev >= 0 && depth > 0)
2392 if ((w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT ||
2393 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) &&
2402 (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER ||
2403 w->selconn != index))
2406 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, HDAA_CTL_OUT, -1, 1);
2410 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
2412 if (wc == NULL || wc->enable == 0)
2414 for (j = 0; j < wc->nconns; j++) {
2415 if (wc->connsenable[j] && wc->conns[j] == nid) {
2417 wc->nid, j, mute, left, right, depth + 1);
2431 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
2432 struct hdaa_audio_as *as = devinfo->as;
2441 if (w == NULL || w->enable == 0)
2448 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
2450 if (wc == NULL || wc->enable == 0)
2452 for (j = 0; j < wc->nconns; j++) {
2453 if (wc->connsenable[j] && wc->conns[j] == nid)
2461 if ((consumers == 2 && (w->bindas < 0 ||
2462 as[w->bindas].hpredir < 0 || as[w->bindas].fakeredir ||
2463 (w->bindseqmask & (1 << 15)) == 0)) ||
2468 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid,
2469 HDAA_CTL_OUT, -1, 1);
2475 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
2479 for (i = 0; i < w->nconns; i++) {
2480 if (w->connsenable[i] == 0)
2486 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid,
2490 hdaa_audio_ctl_dest_volume(pdevinfo, ossdev, w->conns[i], -1,
2501 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
2508 if (pdevinfo->left[dev] == 0) {
2510 lvol = -4000;
2512 lvol = ((pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]) *
2513 pdevinfo->left[dev] + 50) / 100 + pdevinfo->minamp[dev];
2514 if (pdevinfo->right[dev] == 0) {
2516 rvol = -4000;
2518 rvol = ((pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]) *
2519 pdevinfo->right[dev] + 50) / 100 + pdevinfo->minamp[dev];
2520 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
2522 if (w == NULL || w->enable == 0)
2524 if (w->bindas < 0) {
2525 if (pdevinfo->index != 0)
2528 if (w->bindas != pdevinfo->playas &&
2529 w->bindas != pdevinfo->recas)
2533 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
2535 w->nid, -1, mute, lvol, rvol, 0);
2539 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
2540 devinfo->as[w->bindas].dir == HDAA_CTL_OUT) {
2542 w->nid, -1, mute, lvol, rvol, 0);
2546 w->pflags & HDAA_ADC_MONITOR) {
2547 for (j = 0; j < w->nconns; j++) {
2548 if (!w->connsenable[j])
2550 cw = hdaa_widget_get(devinfo, w->conns[j]);
2551 if (cw == NULL || cw->enable == 0)
2553 if (cw->bindas == -1)
2555 if (cw->bindas >= 0 &&
2556 devinfo->as[cw->bindas].dir != HDAA_CTL_IN)
2559 w->nid, j, mute, lvol, rvol, 0);
2563 if (w->ossdev != dev)
2566 w->nid, -1, mute, lvol, rvol, 0);
2567 if (dev == SOUND_MIXER_IMIX && (w->pflags & HDAA_IMIX_AS_DST))
2569 w->nid, -1, mute, lvol, rvol, 0);
2581 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
2588 pdevinfo->left[dev] = left;
2589 pdevinfo->right[dev] = right;
2595 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
2597 if (w == NULL || w->enable == 0)
2599 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX ||
2600 w->param.eapdbtl == HDA_INVALID)
2604 if (i >= devinfo->endnode) {
2606 return (-1);
2608 orig = w->param.eapdbtl;
2610 w->param.eapdbtl &= ~HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD;
2612 w->param.eapdbtl |= HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD;
2613 if (orig != w->param.eapdbtl) {
2616 val = w->param.eapdbtl;
2617 if (devinfo->quirks & HDAA_QUIRK_EAPDINV)
2619 hda_command(devinfo->dev,
2620 HDA_CMD_SET_EAPD_BTL_ENABLE(0, w->nid, val));
2635 * +20dB for mics, -10dB for analog vol, mute for igain, 0dB for others.
2643 if ((pdevinfo->ossmask & (1 << dev)) == 0)
2647 if (resource_int_value(device_get_name(pdevinfo->dev),
2648 device_get_unit(pdevinfo->dev), ossnames[dev], &vol) == 0)
2651 vol = -1;
2659 else if (dev == SOUND_MIXER_VOLUME && !pdevinfo->digital)
2660 amp = -10 * 4; /* -10dB */
2664 (pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]) <= 0) {
2667 vol = ((amp - pdevinfo->minamp[dev]) * 100 +
2668 (pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]) / 2) /
2669 (pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]);
2672 mix_set(pdevinfo->mixer, dev, vol, vol);
2682 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
2693 if (w == NULL || w->enable == 0)
2696 for (i = 0; i < w->nconns; i++) {
2697 if (w->connsenable[i] == 0)
2699 cw = hdaa_widget_get(devinfo, w->conns[i]);
2700 if (cw == NULL || cw->enable == 0 || cw->bindas == -1)
2703 if ((src & cw->ossmask) != 0) {
2704 if (cw->ossdev < 0) {
2706 w->conns[i], depth + 1);
2708 res |= cw->ossmask;
2712 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) {
2714 w->nid, HDAA_CTL_IN, i, 1);
2719 muted = (src & cw->ossmask) ? 0 : 1;
2720 if (muted != ctl->forcemute) {
2721 ctl->forcemute = muted;
2727 device_printf(pdevinfo->dev,
2734 if (w->nconns == 1)
2736 if ((src & cw->ossmask) == 0)
2738 /* If we found requested source - select it and exit. */
2741 device_printf(pdevinfo->dev,
2757 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
2766 if (pdevinfo->recas < 0) {
2770 as = &devinfo->as[pdevinfo->recas];
2772 /* For non-mixed associations we always recording everything. */
2773 if (!as->mixed) {
2779 for (j = 0; j < as->num_chans; j++) {
2780 ch = &devinfo->chans[as->chans[j]];
2781 for (i = 0; ch->io[i] >= 0; i++) {
2782 w = hdaa_widget_get(devinfo, ch->io[i]);
2783 if (w == NULL || w->enable == 0)
2786 ch->io[i], 0);
2799 if (ctl->enable == 0 ||
2800 !(ctl->ossmask & pdevinfo->recsrc))
2802 if (!((pdevinfo->playas >= 0 &&
2803 ctl->widget->bindas == pdevinfo->playas) ||
2804 (pdevinfo->recas >= 0 &&
2805 ctl->widget->bindas == pdevinfo->recas) ||
2806 (pdevinfo->index == 0 &&
2807 ctl->widget->bindas == -2)))
2810 if (pdevinfo->recsrc & (1 << j)) {
2811 ctl->devleft[j] = 0;
2812 ctl->devright[j] = 0;
2813 ctl->devmute[j] = 0;
2823 if ((ret | pdevinfo->recsrc) & (1 << j))
2827 pdevinfo->recsrc = ret;
2843 device_t dev = devinfo->dev;
2847 if (HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap) > 0) {
2849 HDA_CMD_GET_GPI_DATA(0, devinfo->nid));
2851 HDA_CMD_GET_GPI_WAKE_ENABLE_MASK(0, devinfo->nid));
2853 HDA_CMD_GET_GPI_UNSOLICITED_ENABLE_MASK(0, devinfo->nid));
2855 HDA_CMD_GET_GPI_STICKY_MASK(0, devinfo->nid));
2856 for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap); i++) {
2869 device_t dev = devinfo->dev;
2873 if (HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap) > 0) {
2875 HDA_CMD_GET_GPIO_DATA(0, devinfo->nid));
2877 HDA_CMD_GET_GPIO_ENABLE_MASK(0, devinfo->nid));
2879 HDA_CMD_GET_GPIO_DIRECTION(0, devinfo->nid));
2881 HDA_CMD_GET_GPIO_WAKE_ENABLE_MASK(0, devinfo->nid));
2883 HDA_CMD_GET_GPIO_UNSOLICITED_ENABLE_MASK(0, devinfo->nid));
2885 HDA_CMD_GET_GPIO_STICKY_MASK(0, devinfo->nid));
2886 for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap); i++) {
2907 device_t dev = devinfo->dev;
2911 if (HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap) > 0) {
2913 HDA_CMD_GET_GPO_DATA(0, devinfo->nid));
2914 for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap); i++) {
2929 nid = devinfo->nid;
2931 res = hda_command(devinfo->dev,
2933 devinfo->gpio_cap = res;
2936 device_printf(devinfo->dev,
2939 HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap),
2940 HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap),
2941 HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap),
2942 HDA_PARAM_GPIO_COUNT_GPI_WAKE(devinfo->gpio_cap),
2943 HDA_PARAM_GPIO_COUNT_GPI_UNSOL(devinfo->gpio_cap));
2949 res = hda_command(devinfo->dev,
2951 devinfo->supp_stream_formats = res;
2953 res = hda_command(devinfo->dev,
2955 devinfo->supp_pcm_size_rate = res;
2957 res = hda_command(devinfo->dev,
2959 devinfo->outamp_cap = res;
2961 res = hda_command(devinfo->dev,
2963 devinfo->inamp_cap = res;
2965 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
2968 device_printf(devinfo->dev, "Ghost widget! nid=%d!\n", i);
2970 w->devinfo = devinfo;
2971 w->nid = i;
2972 w->enable = 1;
2973 w->selconn = -1;
2974 w->pflags = 0;
2975 w->ossdev = -1;
2976 w->bindas = -1;
2977 w->param.eapdbtl = HDA_INVALID;
2989 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
3007 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
3009 if (w == NULL || w->enable == 0)
3011 if (w->param.outamp_cap != 0)
3013 if (w->param.inamp_cap != 0) {
3014 switch (w->type) {
3017 for (j = 0; j < w->nconns; j++) {
3019 w->conns[j]);
3020 if (cw == NULL || cw->enable == 0)
3031 devinfo->ctlcnt = max;
3040 device_printf(devinfo->dev, "unable to allocate ctls!\n");
3041 devinfo->ctlcnt = 0;
3046 for (i = devinfo->startnode; cnt < max && i < devinfo->endnode; i++) {
3048 device_printf(devinfo->dev, "%s: Ctl overflow!\n",
3053 if (w == NULL || w->enable == 0)
3055 ocap = w->param.outamp_cap;
3056 icap = w->param.inamp_cap;
3064 device_printf(devinfo->dev,
3067 w->nid, offset, step);
3079 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX ||
3080 w->waspin)
3094 device_printf(devinfo->dev,
3097 w->nid, offset, step);
3101 switch (w->type) {
3104 for (j = 0; j < w->nconns; j++) {
3106 device_printf(devinfo->dev,
3112 w->conns[j]);
3113 if (cw == NULL || cw->enable == 0)
3131 device_printf(devinfo->dev,
3144 if (w->type ==
3155 devinfo->ctl = ctls;
3168 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
3170 if (w == NULL || w->enable == 0)
3172 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
3174 if (HDA_CONFIG_DEFAULTCONF_ASSOCIATION(w->wclass.pin.config)
3178 if (j != 15) /* There could be many 1-pin assocs #15 */
3183 devinfo->ascnt = max;
3192 device_printf(devinfo->dev, "unable to allocate assocs!\n");
3193 devinfo->ascnt = 0;
3198 as[i].hpredir = -1;
3201 as[i].location = -1;
3209 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
3211 if (w == NULL || w->enable == 0)
3213 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
3215 assoc = HDA_CONFIG_DEFAULTCONF_ASSOCIATION(w->wclass.pin.config);
3216 seq = HDA_CONFIG_DEFAULTCONF_SEQUENCE(w->wclass.pin.config);
3223 type = w->wclass.pin.config &
3234 /* If this is a first pin - create new association. */
3244 device_printf(devinfo->dev, "%s: Duplicate pin %d (%d) "
3246 __func__, seq, w->nid, j);
3250 device_printf(devinfo->dev, "%s: Pin %d has wrong "
3253 __func__, w->nid, j);
3256 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) {
3258 if (HDA_PARAM_PIN_CAP_HDMI(w->wclass.pin.cap))
3260 if (HDA_PARAM_PIN_CAP_DP(w->wclass.pin.cap))
3263 if (as[cnt].location == -1) {
3265 HDA_CONFIG_DEFAULTCONF_LOCATION(w->wclass.pin.config);
3267 HDA_CONFIG_DEFAULTCONF_LOCATION(w->wclass.pin.config)) {
3268 as[cnt].location = -2;
3274 as[cnt].pins[seq] = w->nid;
3292 device_printf(devinfo->dev,
3295 device_printf(devinfo->dev,
3302 device_printf(devinfo->dev,
3309 devinfo->as = as;
3320 int i, im = -1;
3326 if (w == NULL || w->enable == 0)
3330 device_printf(devinfo->dev,
3332 depth + 1, "", w->nid);
3336 if (w->bindas >= 0 && w->bindas != as) {
3339 device_printf(devinfo->dev,
3341 depth + 1, "", w->nid, w->bindas);
3347 if (w->bindseqmask != 0) {
3350 device_printf(devinfo->dev,
3352 depth + 1, "", w->nid, w->bindseqmask);
3358 /* If this is headphones - allow duplicate first pin. */
3359 if (w->bindseqmask != 0 &&
3360 (w->bindseqmask & (1 << dupseq)) == 0) {
3362 device_printf(devinfo->dev,
3364 depth + 1, "", w->nid, w->bindseqmask);
3370 switch (w->type) {
3377 if ((only == 0 || only == w->nid) &&
3378 (w->nid >= min) && (dupseq < 0 || w->nid ==
3379 devinfo->as[as].dacs[0][dupseq]))
3380 m = w->nid;
3388 for (i = 0; i < w->nconns; i++) {
3389 if (w->connsenable[i] == 0)
3391 if (w->selconn != -1 && w->selconn != i)
3394 w->conns[i], dupseq, min, only, depth + 1)) != 0) {
3403 if (im >= 0 && only && ((w->nconns > 1 &&
3404 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) ||
3405 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR))
3406 w->selconn = im;
3410 w->bindas = as;
3411 w->bindseqmask |= (1 << seq);
3415 device_printf(devinfo->dev,
3417 depth + 1, "", w->nid, m);
3437 if (w == NULL || w->enable == 0)
3440 device_printf(devinfo->dev,
3442 depth + 1, "", w->nid);
3445 if (w->bindas >= 0 && w->bindas != as) {
3447 device_printf(devinfo->dev,
3449 depth + 1, "", w->nid, w->bindas);
3453 if (!mixed && w->bindseqmask != 0) {
3455 device_printf(devinfo->dev,
3457 depth + 1, "", w->nid, w->bindseqmask);
3461 switch (w->type) {
3463 if ((only == 0 || only == w->nid) && (w->nid >= min) &&
3465 m = w->nid;
3475 for (j = devinfo->startnode; j < devinfo->endnode; j++) {
3477 if (wc == NULL || wc->enable == 0)
3479 im = -1;
3480 for (i = 0; i < wc->nconns; i++) {
3481 if (wc->connsenable[i] == 0)
3483 if (wc->conns[i] != nid)
3499 if (im >= 0 && only && ((wc->nconns > 1 &&
3500 wc->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) ||
3501 wc->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR))
3502 wc->selconn = im;
3507 w->bindas = as;
3508 w->bindseqmask |= (1 << seq);
3511 device_printf(devinfo->dev,
3513 depth + 1, "", w->nid, m);
3527 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
3529 if (w == NULL || w->enable == 0)
3531 if (w->bindas == as) {
3533 w->bindseqmask &= ~(1 << seq);
3534 if (w->bindseqmask == 0) {
3535 w->bindas = -1;
3536 w->selconn = -1;
3539 w->bindas = -1;
3540 w->bindseqmask = 0;
3541 w->selconn = -1;
3553 struct hdaa_audio_as *ases = devinfo->as;
3560 /* Check if there is no any left. If so - we succeeded. */
3564 hpredir = (i == 15 && ases[as].fakeredir == 0)?ases[as].hpredir:-1;
3568 device_printf(devinfo->dev,
3579 /* If we failed - return to previous and redo it. */
3581 device_printf(devinfo->dev,
3592 device_printf(devinfo->dev,
3621 struct hdaa_devinfo *devinfo = w1->devinfo;
3625 if (memcmp(&w1->param, &w2->param, sizeof(w1->param)))
3627 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
3629 if (w3 == NULL || w3->enable == 0)
3631 if (w3->bindas != w1->bindas)
3633 if (w3->nconns == 0)
3635 c1 = c2 = -1;
3636 for (j = 0; j < w3->nconns; j++) {
3637 if (w3->connsenable[j] == 0)
3639 if (w3->conns[j] == w1->nid)
3641 if (w3->conns[j] == w2->nid)
3648 if (w3->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)
3660 struct hdaa_devinfo *devinfo = w1->devinfo;
3664 if (memcmp(&w1->param, &w2->param, sizeof(w1->param)))
3666 if (w1->nconns != 1 || w2->nconns != 1)
3668 if (w1->conns[0] == w2->conns[0])
3670 w3 = hdaa_widget_get(devinfo, w1->conns[0]);
3671 if (w3 == NULL || w3->enable == 0)
3673 w4 = hdaa_widget_get(devinfo, w2->conns[0]);
3674 if (w4 == NULL || w4->enable == 0)
3676 if (w3->bindas == w4->bindas && w3->bindseqmask == w4->bindseqmask)
3678 if (w4->bindas >= 0)
3680 if (w3->type != w4->type)
3682 if (memcmp(&w3->param, &w4->param, sizeof(w3->param)))
3684 if (w3->nconns != w4->nconns)
3686 for (i = 0; i < w3->nconns; i++) {
3687 if (w3->conns[i] != w4->conns[i])
3699 struct hdaa_audio_as *as = &devinfo->as[asid];
3705 device_printf(devinfo->dev,
3708 (as->dir == HDAA_CTL_OUT) ? "DA" : "AD",
3709 asid, as->index);
3713 pos = -1;
3715 if (as->dacs[0][i] <= 0)
3717 if (pos >= 0 && as->dacs[0][i] != as->dacs[0][pos])
3722 nid1 = as->dacs[0][pos];
3725 for (nid2 = devinfo->startnode; nid2 < devinfo->endnode; nid2++) {
3727 if (w2 == NULL || w2->enable == 0)
3729 if (w2->bindas >= 0)
3731 if (w1->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT) {
3732 if (w2->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT)
3737 if (w2->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT)
3743 if (nid2 >= devinfo->endnode)
3745 w2->bindas = w1->bindas;
3746 w2->bindseqmask = w1->bindseqmask;
3747 if (w1->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
3749 device_printf(devinfo->dev,
3752 w1 = hdaa_widget_get(devinfo, w1->conns[0]);
3753 w2 = hdaa_widget_get(devinfo, w2->conns[0]);
3754 w2->bindas = w1->bindas;
3755 w2->bindseqmask = w1->bindseqmask;
3758 device_printf(devinfo->dev,
3763 if (as->dacs[0][i] <= 0)
3765 as->dacs[as->num_chans][i] = nid2;
3767 as->num_chans++;
3776 struct hdaa_audio_as *ases = devinfo->as;
3780 for (j = devinfo->startnode; j < devinfo->endnode; j++) {
3782 if (w == NULL || w->enable == 0)
3784 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT)
3786 if (w->bindas >= 0 && w->bindas != as)
3795 device_printf(devinfo->dev,
3802 /* If we failed - return to previous and redo it. */
3804 device_printf(devinfo->dev,
3808 hdaa_audio_undo_trace(devinfo, as, -1);
3814 device_printf(devinfo->dev,
3832 struct hdaa_audio_as *ases = devinfo->as;
3839 /* Check if there is no any left. If so - we succeeded. */
3846 device_printf(devinfo->dev,
3855 /* If we failed - return to previous and redo it. */
3857 device_printf(devinfo->dev,
3866 device_printf(devinfo->dev,
3890 struct hdaa_audio_as *ases = devinfo->as;
3898 if (w == NULL || w->enable == 0)
3901 device_printf(devinfo->dev,
3903 depth + 1, "", w->nid);
3906 if (depth > 0 && w->bindas != -1) {
3907 if (w->bindas < 0 || ases[w->bindas].dir == HDAA_CTL_OUT) {
3909 device_printf(devinfo->dev,
3911 depth + 1, "", w->nid, w->bindas);
3913 if (w->bindas >= 0)
3914 w->pflags |= HDAA_ADC_MONITOR;
3918 device_printf(devinfo->dev,
3920 depth + 1, "", w->nid, w->bindas);
3926 switch (w->type) {
3937 for (j = devinfo->startnode; j < devinfo->endnode; j++) {
3939 if (wc == NULL || wc->enable == 0)
3941 for (i = 0; i < wc->nconns; i++) {
3942 if (wc->connsenable[i] == 0)
3944 if (wc->conns[i] != nid)
3949 if (wc->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR &&
3950 wc->selconn == -1)
3951 wc->selconn = i;
3957 if (res && w->bindas == -1)
3958 w->bindas = -2;
3961 device_printf(devinfo->dev,
3963 depth + 1, "", w->nid, res);
3969 * Trace extra associations (beeper, monitor)
3974 struct hdaa_audio_as *as = devinfo->as;
3982 device_printf(devinfo->dev,
3985 for (j = devinfo->startnode; j < devinfo->endnode; j++) {
3987 if (w == NULL || w->enable == 0)
3989 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)
3991 if (w->bindas < 0 || as[w->bindas].dir != HDAA_CTL_IN)
3994 device_printf(devinfo->dev,
3998 if (hdaa_audio_trace_to_out(devinfo, w->nid, 0)) {
4000 device_printf(devinfo->dev,
4002 w->nid);
4004 w->ossdev = SOUND_MIXER_IMIX;
4012 device_printf(devinfo->dev,
4015 for (j = devinfo->startnode; j < devinfo->endnode; j++) {
4017 if (w == NULL || w->enable == 0)
4019 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
4021 if (w->bindas < 0 || as[w->bindas].dir != HDAA_CTL_IN)
4024 device_printf(devinfo->dev,
4028 if (hdaa_audio_trace_to_out(devinfo, w->nid, 0)) {
4030 device_printf(devinfo->dev,
4032 w->nid);
4037 /* Beeper */
4039 device_printf(devinfo->dev,
4040 "Tracing beeper\n");
4042 for (j = devinfo->startnode; j < devinfo->endnode; j++) {
4044 if (w == NULL || w->enable == 0)
4046 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_BEEP_WIDGET)
4049 device_printf(devinfo->dev,
4053 if (hdaa_audio_trace_to_out(devinfo, w->nid, 0)) {
4055 device_printf(devinfo->dev,
4060 w->bindas = -2;
4070 struct hdaa_audio_as *as = devinfo->as;
4073 for (j = 0; j < devinfo->ascnt; j++) {
4077 if (devinfo->num_chans == 0) {
4078 devinfo->chans = malloc(sizeof(struct hdaa_chan) * cnt,
4080 if (devinfo->chans == NULL) {
4081 device_printf(devinfo->dev,
4086 devinfo->chans = (struct hdaa_chan *)realloc(devinfo->chans,
4087 sizeof(struct hdaa_chan) * (devinfo->num_chans + cnt),
4089 if (devinfo->chans == NULL) {
4090 devinfo->num_chans = 0;
4091 device_printf(devinfo->dev,
4096 for (j = 0; j < devinfo->num_chans; j++)
4097 devinfo->chans[j].caps.fmtlist = devinfo->chans[j].fmtlist;
4099 free = devinfo->num_chans;
4100 devinfo->num_chans += cnt;
4103 devinfo->chans[j].devinfo = devinfo;
4104 devinfo->chans[j].as = -1;
4108 for (j = 0; j < devinfo->ascnt; j++) {
4112 devinfo->chans[free].as = j;
4113 devinfo->chans[free].asindex = i;
4114 devinfo->chans[free].dir =
4116 hdaa_pcmchannel_setup(&devinfo->chans[free]);
4130 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4132 if (w == NULL || w->enable == 0)
4134 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_POWER_WIDGET ||
4135 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_VOLUME_WIDGET) {
4136 w->enable = 0;
4138 device_printf(devinfo->dev,
4140 " non-audio type.\n",
4141 w->nid);
4155 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4157 if (w == NULL || w->enable == 0)
4159 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) {
4160 if ((w->wclass.pin.config &
4163 w->enable = 0;
4165 device_printf(devinfo->dev,
4168 w->nid);
4170 } else if ((w->wclass.pin.config &
4172 w->enable = 0;
4174 device_printf(devinfo->dev,
4177 w->nid);
4187 if (ctl->enable == 0)
4189 if (ctl->widget->enable == 0 ||
4190 (ctl->childwidget != NULL &&
4191 ctl->childwidget->enable == 0)) {
4192 ctl->forcemute = 1;
4193 ctl->muted = HDAA_AMP_MUTE_ALL;
4194 ctl->left = 0;
4195 ctl->right = 0;
4196 ctl->enable = 0;
4197 if (ctl->ndir == HDAA_CTL_IN)
4198 ctl->widget->connsenable[ctl->index] = 0;
4201 device_printf(devinfo->dev,
4204 ctl->widget->nid,
4205 (ctl->childwidget != NULL)?
4206 ctl->childwidget->nid:-1);
4211 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4213 if (w == NULL || w->enable == 0)
4216 for (j = 0; j < w->nconns; j++) {
4217 if (w->connsenable[j]) {
4218 cw = hdaa_widget_get(devinfo, w->conns[j]);
4219 if (cw == NULL || cw->enable == 0) {
4220 w->connsenable[j] = 0;
4222 device_printf(devinfo->dev,
4230 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR &&
4231 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)
4235 for (j = 0; j < w->nconns; j++) {
4236 if (w->connsenable[j]) {
4242 w->enable = 0;
4245 device_printf(devinfo->dev,
4247 " inputs disabled.\n", w->nid);
4251 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR &&
4252 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)
4255 for (k = devinfo->startnode; k < devinfo->endnode; k++) {
4257 if (cw == NULL || cw->enable == 0)
4259 for (j = 0; j < cw->nconns; j++) {
4260 if (cw->connsenable[j] && cw->conns[j] == i) {
4267 w->enable = 0;
4270 device_printf(devinfo->dev,
4272 " consumers disabled.\n", w->nid);
4283 struct hdaa_audio_as *as = devinfo->as;
4289 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4291 if (w == NULL || w->enable == 0)
4293 if (w->bindas == -1) {
4294 w->enable = 0;
4296 device_printf(devinfo->dev,
4298 w->nid);
4304 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4306 if (w == NULL || w->enable == 0)
4308 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
4310 if (w->bindas < 0)
4312 if (as[w->bindas].dir == HDAA_CTL_IN) {
4313 for (j = 0; j < w->nconns; j++) {
4314 if (w->connsenable[j] == 0)
4316 w->connsenable[j] = 0;
4318 device_printf(devinfo->dev,
4324 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid,
4325 HDAA_CTL_IN, -1, 1);
4326 if (ctl && ctl->enable) {
4327 ctl->forcemute = 1;
4328 ctl->muted = HDAA_AMP_MUTE_ALL;
4329 ctl->left = 0;
4330 ctl->right = 0;
4331 ctl->enable = 0;
4334 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid,
4335 HDAA_CTL_OUT, -1, 1);
4336 if (ctl && ctl->enable) {
4337 ctl->forcemute = 1;
4338 ctl->muted = HDAA_AMP_MUTE_ALL;
4339 ctl->left = 0;
4340 ctl->right = 0;
4341 ctl->enable = 0;
4343 for (k = devinfo->startnode; k < devinfo->endnode; k++) {
4345 if (cw == NULL || cw->enable == 0)
4347 for (j = 0; j < cw->nconns; j++) {
4348 if (cw->connsenable[j] && cw->conns[j] == i) {
4349 cw->connsenable[j] = 0;
4351 device_printf(devinfo->dev,
4356 if (cw->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
4357 cw->nconns > 1)
4361 if (ctl && ctl->enable) {
4362 ctl->forcemute = 1;
4363 ctl->muted = HDAA_AMP_MUTE_ALL;
4364 ctl->left = 0;
4365 ctl->right = 0;
4366 ctl->enable = 0;
4378 struct hdaa_audio_as *as = devinfo->as;
4383 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4385 if (w == NULL || w->enable == 0)
4387 if (w->nconns <= 1)
4389 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)
4391 if (w->bindas < 0 || as[w->bindas].dir == HDAA_CTL_IN)
4393 for (j = 0; j < w->nconns; j++) {
4394 if (w->connsenable[j] == 0)
4396 if (w->selconn < 0 || w->selconn == j)
4398 w->connsenable[j] = 0;
4400 device_printf(devinfo->dev,
4412 struct hdaa_audio_as *ases = devinfo->as;
4419 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4421 if (w == NULL || w->enable == 0)
4423 if (w->nconns <= 1)
4425 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)
4427 /* Allow any -> mix */
4428 if (w->bindas == -2)
4430 for (j = 0; j < w->nconns; j++) {
4431 if (w->connsenable[j] == 0)
4433 cw = hdaa_widget_get(devinfo, w->conns[j]);
4434 if (cw == NULL || w->enable == 0)
4436 /* Allow mix -> out. */
4437 if (cw->bindas == -2 && w->bindas >= 0 &&
4438 ases[w->bindas].dir == HDAA_CTL_OUT)
4440 /* Allow mix -> mixed-in. */
4441 if (cw->bindas == -2 && w->bindas >= 0 &&
4442 ases[w->bindas].mixed)
4444 /* Allow in -> mix. */
4445 if ((w->pflags & HDAA_ADC_MONITOR) &&
4446 cw->bindas >= 0 &&
4447 ases[cw->bindas].dir == HDAA_CTL_IN)
4450 if (w->bindas == cw->bindas &&
4451 (w->bindseqmask & cw->bindseqmask) != 0)
4453 w->connsenable[j] = 0;
4455 device_printf(devinfo->dev,
4458 i, j, cw->nid);
4465 if (ctl->enable == 0 || ctl->childwidget == NULL)
4467 /* Allow any -> mix */
4468 if (ctl->widget->bindas == -2)
4470 /* Allow mix -> out. */
4471 if (ctl->childwidget->bindas == -2 &&
4472 ctl->widget->bindas >= 0 &&
4473 ases[ctl->widget->bindas].dir == HDAA_CTL_OUT)
4475 /* Allow mix -> mixed-in. */
4476 if (ctl->childwidget->bindas == -2 &&
4477 ctl->widget->bindas >= 0 &&
4478 ases[ctl->widget->bindas].mixed)
4480 /* Allow in -> mix. */
4481 if ((ctl->widget->pflags & HDAA_ADC_MONITOR) &&
4482 ctl->childwidget->bindas >= 0 &&
4483 ases[ctl->childwidget->bindas].dir == HDAA_CTL_IN)
4486 if (ctl->widget->bindas == ctl->childwidget->bindas &&
4487 (ctl->widget->bindseqmask & ctl->childwidget->bindseqmask) != 0)
4489 ctl->forcemute = 1;
4490 ctl->muted = HDAA_AMP_MUTE_ALL;
4491 ctl->left = 0;
4492 ctl->right = 0;
4493 ctl->enable = 0;
4494 if (ctl->ndir == HDAA_CTL_IN)
4495 ctl->widget->connsenable[ctl->index] = 0;
4497 device_printf(devinfo->dev,
4500 ctl->widget->nid,
4501 ctl->childwidget->nid);
4523 if (w == NULL || w->enable == 0)
4528 for (j = 0; j < w->nconns; j++) {
4529 if (!w->connsenable[j])
4535 /* If this is not a first step - use input mixer.
4538 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)) {
4539 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, HDAA_CTL_IN,
4542 ctl->ossmask |= (1 << ossdev);
4551 /* If widget has own ossdev - not traverse it.
4553 if (w->ossdev >= 0 && depth > 0)
4557 if ((w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT ||
4558 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) &&
4563 w->ossmask |= (1 << ossdev);
4570 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER)
4574 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, HDAA_CTL_OUT, -1, 1);
4576 ctl->ossmask |= (1 << ossdev);
4586 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4588 if (wc == NULL || wc->enable == 0)
4590 for (j = 0; j < wc->nconns; j++) {
4591 if (wc->connsenable[j] && wc->conns[j] == nid) {
4594 wc->nid, j, ossdev, ctlable, depth + 1,
4621 struct hdaa_audio_as *as = devinfo->as;
4630 if (w == NULL || w->enable == 0)
4637 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4639 if (wc == NULL || wc->enable == 0)
4641 for (j = 0; j < wc->nconns; j++) {
4642 if (wc->connsenable[j] && wc->conns[j] == nid)
4650 if ((consumers == 2 && (w->bindas < 0 ||
4651 as[w->bindas].hpredir < 0 || as[w->bindas].fakeredir ||
4652 (w->bindseqmask & (1 << 15)) == 0)) ||
4657 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid,
4658 HDAA_CTL_OUT, -1, 1);
4660 ctl->ossmask |= (1 << ossdev);
4670 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
4675 for (i = 0; i < w->nconns; i++) {
4676 if (w->connsenable[i] == 0)
4681 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid,
4684 ctl->ossmask |= (1 << ossdev);
4691 found += hdaa_audio_ctl_dest_amp(devinfo, w->conns[i], -1, ossdev,
4714 struct hdaa_audio_as *as = devinfo->as;
4717 int type = -1, use, used = 0;
4720 SOUND_MIXER_LINE3, -1 }, /* line */
4721 { SOUND_MIXER_MONITOR, SOUND_MIXER_MIC, -1 }, /* int mic */
4722 { SOUND_MIXER_MIC, SOUND_MIXER_MONITOR, -1 }, /* ext mic */
4723 { SOUND_MIXER_CD, -1 }, /* cd */
4724 { SOUND_MIXER_SPEAKER, -1 }, /* speaker */
4726 -1 }, /* digital */
4731 -1 } /* others */
4735 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4737 if (w == NULL || w->enable == 0)
4739 if (w->bindas == -1)
4741 use = -1;
4742 switch (w->type) {
4744 if (as[w->bindas].dir == HDAA_CTL_OUT)
4746 type = -1;
4747 switch (w->wclass.pin.config & HDA_CONFIG_DEFAULTCONF_DEVICE_MASK) {
4752 if ((w->wclass.pin.config & HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK)
4768 if (type == -1)
4788 w->ossdev = use;
4792 /* Semi-known names */
4793 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4795 if (w == NULL || w->enable == 0)
4797 if (w->ossdev >= 0)
4799 if (w->bindas == -1)
4801 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
4803 if (as[w->bindas].dir == HDAA_CTL_OUT)
4805 type = -1;
4806 switch (w->wclass.pin.config & HDA_CONFIG_DEFAULTCONF_DEVICE_MASK) {
4821 if (type == -1)
4829 w->ossdev = types[type][j];
4834 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4836 if (w == NULL || w->enable == 0)
4838 if (w->ossdev >= 0)
4840 if (w->bindas == -1)
4842 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
4844 if (as[w->bindas].dir == HDAA_CTL_OUT)
4852 w->ossdev = types[6][j];
4861 struct hdaa_audio_as *as = devinfo->as;
4865 for (j = 0; j < devinfo->ascnt; j++) {
4869 device_printf(devinfo->dev,
4888 device_printf(devinfo->dev,
4894 device_printf(devinfo->dev,
4903 for (j = 0; j < devinfo->ascnt; j++) {
4909 /* Trace mixer and beeper pseudo associations. */
4921 struct hdaa_devinfo *devinfo = w->devinfo;
4924 if (w->bindas >= 0)
4925 pdevinfo = devinfo->as[w->bindas].pdevinfo;
4927 pdevinfo = &devinfo->devs[0];
4929 pdevinfo->ossmask |= (1 << ossdev);
4932 if (pdevinfo->minamp[ossdev] == 0 && pdevinfo->maxamp[ossdev] == 0) {
4933 pdevinfo->minamp[ossdev] = minamp;
4934 pdevinfo->maxamp[ossdev] = maxamp;
4936 pdevinfo->minamp[ossdev] = imax(pdevinfo->minamp[ossdev], minamp);
4937 pdevinfo->maxamp[ossdev] = imin(pdevinfo->maxamp[ossdev], maxamp);
4948 struct hdaa_audio_as *as = devinfo->as;
4953 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
4955 if (w == NULL || w->enable == 0)
4958 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT ||
4959 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_BEEP_WIDGET ||
4960 (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
4961 as[w->bindas].dir == HDAA_CTL_IN)) {
4962 if (w->ossdev < 0)
4964 found = hdaa_audio_ctl_source_amp(devinfo, w->nid, -1,
4965 w->ossdev, 1, 0, &minamp, &maxamp);
4966 hdaa_adjust_amp(w, w->ossdev, found, minamp, maxamp);
4967 } else if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
4968 found = hdaa_audio_ctl_dest_amp(devinfo, w->nid, -1,
4971 } else if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
4972 as[w->bindas].dir == HDAA_CTL_OUT) {
4973 found = hdaa_audio_ctl_dest_amp(devinfo, w->nid, -1,
4977 if (w->ossdev == SOUND_MIXER_IMIX) {
4979 found = hdaa_audio_ctl_source_amp(devinfo, w->nid, -1,
4980 w->ossdev, 1, 0, &minamp, &maxamp);
4983 as source - try to control it as destination. */
4984 found += hdaa_audio_ctl_dest_amp(devinfo, w->nid, -1,
4985 w->ossdev, 0, &minamp, &maxamp);
4986 w->pflags |= HDAA_IMIX_AS_DST;
4988 hdaa_adjust_amp(w, w->ossdev, found, minamp, maxamp);
4990 if (w->pflags & HDAA_ADC_MONITOR) {
4991 for (j = 0; j < w->nconns; j++) {
4992 if (!w->connsenable[j])
4994 cw = hdaa_widget_get(devinfo, w->conns[j]);
4995 if (cw == NULL || cw->enable == 0)
4997 if (cw->bindas == -1)
4999 if (cw->bindas >= 0 &&
5000 as[cw->bindas].dir != HDAA_CTL_IN)
5004 w->nid, j, SOUND_MIXER_IGAIN, 0,
5016 struct hdaa_audio_as *as = devinfo->as;
5021 for (i = 0; i < devinfo->nodecnt; i++) {
5022 w = &devinfo->widget[i];
5025 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
5026 w->waspin == 0)
5029 pincap = w->wclass.pin.cap;
5032 if (devinfo->init_clear) {
5033 w->wclass.pin.ctrl &= ~(
5040 if (w->enable == 0) {
5043 } else if (w->waspin) {
5044 /* Enable input for beeper input. */
5045 w->wclass.pin.ctrl |=
5047 } else if (w->bindas < 0 || as[w->bindas].enable == 0) {
5050 } else if (as[w->bindas].dir == HDAA_CTL_IN) {
5053 w->wclass.pin.ctrl |=
5056 if ((devinfo->quirks & HDAA_QUIRK_IVREF100) &&
5058 w->wclass.pin.ctrl |=
5061 else if ((devinfo->quirks & HDAA_QUIRK_IVREF80) &&
5063 w->wclass.pin.ctrl |=
5066 else if ((devinfo->quirks & HDAA_QUIRK_IVREF50) &&
5068 w->wclass.pin.ctrl |=
5074 w->wclass.pin.ctrl |=
5078 (w->wclass.pin.config &
5081 w->wclass.pin.ctrl |=
5084 if ((devinfo->quirks & HDAA_QUIRK_OVREF100) &&
5086 w->wclass.pin.ctrl |=
5089 else if ((devinfo->quirks & HDAA_QUIRK_OVREF80) &&
5091 w->wclass.pin.ctrl |=
5094 else if ((devinfo->quirks & HDAA_QUIRK_OVREF50) &&
5096 w->wclass.pin.ctrl |=
5111 if (ctl->enable == 0 || ctl->ossmask != 0) {
5119 z = ctl->offset;
5120 if (z > ctl->step)
5121 z = ctl->step;
5132 numgpio = HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap);
5133 if (devinfo->gpio != 0 && numgpio != 0) {
5134 gdata = hda_command(devinfo->dev,
5135 HDA_CMD_GET_GPIO_DATA(0, devinfo->nid));
5136 gmask = hda_command(devinfo->dev,
5137 HDA_CMD_GET_GPIO_ENABLE_MASK(0, devinfo->nid));
5138 gdir = hda_command(devinfo->dev,
5139 HDA_CMD_GET_GPIO_DIRECTION(0, devinfo->nid));
5141 if ((devinfo->gpio & HDAA_GPIO_MASK(i)) ==
5146 } else if ((devinfo->gpio & HDAA_GPIO_MASK(i)) ==
5151 } else if ((devinfo->gpio & HDAA_GPIO_MASK(i)) ==
5154 } else if ((devinfo->gpio & HDAA_GPIO_MASK(i)) ==
5161 device_printf(devinfo->dev, "GPIO commit\n");
5163 hda_command(devinfo->dev,
5164 HDA_CMD_SET_GPIO_ENABLE_MASK(0, devinfo->nid, gmask));
5165 hda_command(devinfo->dev,
5166 HDA_CMD_SET_GPIO_DIRECTION(0, devinfo->nid, gdir));
5167 hda_command(devinfo->dev,
5168 HDA_CMD_SET_GPIO_DATA(0, devinfo->nid, gdata));
5181 numgpo = HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap);
5182 if (devinfo->gpo != 0 && numgpo != 0) {
5183 gdata = hda_command(devinfo->dev,
5184 HDA_CMD_GET_GPO_DATA(0, devinfo->nid));
5186 if ((devinfo->gpio & HDAA_GPIO_MASK(i)) ==
5189 } else if ((devinfo->gpio & HDAA_GPIO_MASK(i)) ==
5195 device_printf(devinfo->dev, "GPO commit\n");
5197 hda_command(devinfo->dev,
5198 HDA_CMD_SET_GPO_DATA(0, devinfo->nid, gdata));
5215 for (i = 0; i < devinfo->nodecnt; i++) {
5216 w = &devinfo->widget[i];
5219 if (w->selconn == -1)
5220 w->selconn = 0;
5221 if (w->nconns > 0)
5222 hdaa_widget_connection_select(w, w->selconn);
5223 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX ||
5224 w->waspin) {
5225 hda_command(devinfo->dev,
5226 HDA_CMD_SET_PIN_WIDGET_CTRL(0, w->nid,
5227 w->wclass.pin.ctrl));
5229 if (w->param.eapdbtl != HDA_INVALID) {
5232 val = w->param.eapdbtl;
5233 if (devinfo->quirks &
5236 hda_command(devinfo->dev,
5237 HDA_CMD_SET_EAPD_BTL_ENABLE(0, w->nid,
5251 hda_command(devinfo->dev,
5253 devinfo->nid, HDA_CMD_POWER_STATE_D0));
5256 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
5257 hda_command(devinfo->dev,
5267 struct hdaa_devinfo *devinfo = ch->devinfo;
5268 struct hdaa_audio_as *as = devinfo->as;
5274 ch->caps = hdaa_caps;
5275 ch->caps.fmtlist = ch->fmtlist;
5276 ch->bit16 = 1;
5277 ch->bit32 = 0;
5278 ch->pcmrates[0] = 48000;
5279 ch->pcmrates[1] = 0;
5280 ch->stripecap = 0xff;
5286 fmtcap = devinfo->supp_stream_formats;
5287 pcmcap = devinfo->supp_pcm_size_rate;
5291 if (ch->as < 0)
5294 if (as[ch->as].dacs[ch->asindex][i] <= 0)
5298 if (ch->io[j] == as[ch->as].dacs[ch->asindex][i])
5304 w = hdaa_widget_get(devinfo, as[ch->as].dacs[ch->asindex][i]);
5305 if (w == NULL || w->enable == 0)
5307 cap = w->param.supp_stream_formats;
5313 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap))
5317 pcmcap = w->param.supp_pcm_size_rate;
5320 pcmcap &= w->param.supp_pcm_size_rate;
5322 ch->io[ret++] = as[ch->as].dacs[ch->asindex][i];
5323 ch->stripecap &= w->wclass.conv.stripecap;
5325 if (i == 15 && as[ch->as].hpredir >= 0)
5327 channels += HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap) + 1;
5328 if (HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap) != 1)
5332 ch->io[ret] = -1;
5333 ch->channels = channels;
5335 if (as[ch->as].fakeredir)
5336 ret--;
5338 if ((!onlystereo) || as[ch->as].mixed)
5341 as[ch->as].pinset = pinset;
5343 ch->supp_stream_formats = fmtcap;
5344 ch->supp_pcm_size_rate = pcmcap;
5357 ch->bit16 = 1;
5359 ch->bit16 = 0;
5361 ch->bit32 = 3;
5363 ch->bit32 = 2;
5365 ch->bit32 = 4;
5366 if (!(devinfo->quirks & HDAA_QUIRK_FORCESTEREO)) {
5367 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 1, 0);
5368 if (ch->bit32)
5369 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 1, 0);
5372 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 2, 0);
5373 if (ch->bit32)
5374 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 2, 0);
5377 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 3, 0);
5378 if (ch->bit32)
5379 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 3, 0);
5380 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 3, 1);
5381 if (ch->bit32)
5382 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 3, 1);
5385 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 4, 0);
5386 if (ch->bit32)
5387 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 4, 0);
5389 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 4, 1);
5390 if (ch->bit32)
5391 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 4, 1);
5395 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 5, 0);
5396 if (ch->bit32)
5397 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 5, 0);
5398 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 5, 1);
5399 if (ch->bit32)
5400 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 5, 1);
5403 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 6, 1);
5404 if (ch->bit32)
5405 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 6, 1);
5407 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 6, 0);
5408 if (ch->bit32)
5409 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 6, 0);
5413 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 7, 0);
5414 if (ch->bit32)
5415 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 7, 0);
5416 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 7, 1);
5417 if (ch->bit32)
5418 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 7, 1);
5421 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 8, 1);
5422 if (ch->bit32)
5423 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 8, 1);
5427 ch->fmtlist[i++] = SND_FORMAT(AFMT_AC3, 2, 0);
5429 ch->fmtlist[i++] = SND_FORMAT(AFMT_AC3, 8, 1);
5432 ch->fmtlist[i] = 0;
5435 ch->pcmrates[i++] = 8000;
5437 ch->pcmrates[i++] = 11025;
5439 ch->pcmrates[i++] = 16000;
5441 ch->pcmrates[i++] = 22050;
5443 ch->pcmrates[i++] = 32000;
5445 ch->pcmrates[i++] = 44100;
5447 ch->pcmrates[i++] = 48000;
5449 ch->pcmrates[i++] = 88200;
5451 ch->pcmrates[i++] = 96000;
5453 ch->pcmrates[i++] = 176400;
5455 ch->pcmrates[i++] = 192000;
5457 ch->pcmrates[i] = 0;
5459 ch->caps.minspeed = ch->pcmrates[0];
5460 ch->caps.maxspeed = ch->pcmrates[i - 1];
5470 struct hdaa_audio_as *as = devinfo->as;
5473 for (i = 0; i < devinfo->ascnt; i++) {
5488 devinfo->num_devs =
5490 devinfo->devs = malloc(devinfo->num_devs *
5492 if (devinfo->devs == NULL) {
5493 device_printf(devinfo->dev,
5497 for (i = 0; i < devinfo->num_devs; i++) {
5498 devinfo->devs[i].index = i;
5499 devinfo->devs[i].devinfo = devinfo;
5500 devinfo->devs[i].playas = -1;
5501 devinfo->devs[i].recas = -1;
5502 devinfo->devs[i].digital = 255;
5504 for (i = 0; i < devinfo->ascnt; i++) {
5507 for (j = 0; j < devinfo->num_devs; j++) {
5508 if (devinfo->devs[j].digital != 255 &&
5509 (!devinfo->devs[j].digital) !=
5513 if (devinfo->devs[j].recas >= 0)
5515 devinfo->devs[j].recas = i;
5517 if (devinfo->devs[j].playas >= 0)
5519 devinfo->devs[j].playas = i;
5521 as[i].pdevinfo = &devinfo->devs[j];
5523 devinfo->chans[as[i].chans[k]].pdevinfo =
5524 &devinfo->devs[j];
5526 devinfo->devs[j].digital = as[i].digital;
5537 for (i = 0; i < devinfo->num_devs; i++) {
5538 struct hdaa_pcm_devinfo *pdevinfo = &devinfo->devs[i];
5540 pdevinfo->dev = device_add_child(devinfo->dev, "pcm", DEVICE_UNIT_ANY);
5541 device_set_ivars(pdevinfo->dev, (void *)pdevinfo);
5548 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
5566 if (ctl->enable == 0 ||
5567 ctl->widget->enable == 0)
5569 if (!((pdevinfo->playas >= 0 &&
5570 ctl->widget->bindas == pdevinfo->playas) ||
5571 (pdevinfo->recas >= 0 &&
5572 ctl->widget->bindas == pdevinfo->recas) ||
5573 (ctl->widget->bindas == -2 && pdevinfo->index == 0)))
5575 if ((ctl->ossmask & (1 << j)) == 0)
5580 device_printf(pdevinfo->dev, "%s", banner);
5582 device_printf(pdevinfo->dev, "Unknown Ctl");
5587 if (pdevinfo->ossmask & (1 << j)) {
5589 pdevinfo->minamp[j] / 4,
5590 pdevinfo->maxamp[j] / 4);
5595 device_printf(pdevinfo->dev, " +- ctl %2d (nid %3d %s", i,
5596 ctl->widget->nid,
5597 (ctl->ndir == HDAA_CTL_IN)?"in ":"out");
5598 if (ctl->ndir == HDAA_CTL_IN && ctl->ndir == ctl->dir)
5599 printf(" %2d): ", ctl->index);
5602 if (ctl->step > 0) {
5606 ctl->step + 1,
5607 ctl->mute?" + mute":"");
5609 printf("%s\n", ctl->mute?"mute":"");
5613 device_printf(pdevinfo->dev, "\n");
5676 pincap = w->wclass.pin.cap;
5678 device_printf(w->devinfo->dev, " Pin cap: 0x%08x", pincap);
5716 device_printf(w->devinfo->dev, " Pin config: 0x%08x\n",
5717 w->wclass.pin.config);
5718 device_printf(w->devinfo->dev, " Pin control: 0x%08x", w->wclass.pin.ctrl);
5719 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE)
5721 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE)
5723 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_OUT_ENABLE)
5725 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) {
5726 if ((w->wclass.pin.ctrl &
5729 else if ((w->wclass.pin.ctrl &
5733 if ((w->wclass.pin.ctrl &
5744 device_printf(w->devinfo->dev, "%2d %08x %-2d %-2d "
5745 "%-13s %-5s %-7s %-10s %-7s %d%s\n",
5746 w->nid, conf,
5755 (w->enable == 0)?" DISA":"");
5764 device_printf(devinfo->dev, "nid 0x as seq "
5766 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
5770 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
5772 hdaa_dump_pin_config(w, w->wclass.pin.config);
5789 ((0 - offset) * (size + 1)) / 4,
5790 ((step - offset) * (size + 1)) / 4);
5800 device_printf(devinfo->dev, "\n");
5801 device_printf(devinfo->dev, "Default parameters:\n");
5802 hdaa_dump_audio_formats(devinfo->dev,
5803 devinfo->supp_stream_formats,
5804 devinfo->supp_pcm_size_rate);
5805 hdaa_dump_amp(devinfo->dev, devinfo->inamp_cap, " Input");
5806 hdaa_dump_amp(devinfo->dev, devinfo->outamp_cap, "Output");
5807 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
5810 device_printf(devinfo->dev, "Ghost widget nid=%d\n", i);
5813 device_printf(devinfo->dev, "\n");
5814 device_printf(devinfo->dev, " nid: %d%s\n", w->nid,
5815 (w->enable == 0) ? " [DISABLED]" : "");
5816 device_printf(devinfo->dev, " Name: %s\n", w->name);
5817 device_printf(devinfo->dev, " Widget cap: 0x%08x",
5818 w->param.widget_cap);
5819 if (w->param.widget_cap & 0x0ee1) {
5820 if (HDA_PARAM_AUDIO_WIDGET_CAP_LR_SWAP(w->param.widget_cap))
5822 if (HDA_PARAM_AUDIO_WIDGET_CAP_POWER_CTRL(w->param.widget_cap))
5824 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap))
5826 if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(w->param.widget_cap))
5828 if (HDA_PARAM_AUDIO_WIDGET_CAP_PROC_WIDGET(w->param.widget_cap))
5830 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap))
5832 1 << (fls(w->wclass.conv.stripecap) - 1));
5833 j = HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap);
5840 if (w->bindas != -1) {
5841 device_printf(devinfo->dev, " Association: %d (0x%04x)\n",
5842 w->bindas, w->bindseqmask);
5844 if (w->ossmask != 0 || w->ossdev >= 0) {
5845 device_printf(devinfo->dev, " OSS: %s",
5846 hdaa_audio_ctl_ossmixer_mask2allname(w->ossmask, buf, sizeof(buf)));
5847 if (w->ossdev >= 0)
5848 printf(" (%s)", ossnames[w->ossdev]);
5851 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT ||
5852 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) {
5853 hdaa_dump_audio_formats(devinfo->dev,
5854 w->param.supp_stream_formats,
5855 w->param.supp_pcm_size_rate);
5856 } else if (w->type ==
5857 HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || w->waspin)
5859 if (w->param.eapdbtl != HDA_INVALID)
5860 device_printf(devinfo->dev, " EAPD: 0x%08x\n",
5861 w->param.eapdbtl);
5862 if (HDA_PARAM_AUDIO_WIDGET_CAP_OUT_AMP(w->param.widget_cap) &&
5863 w->param.outamp_cap != 0)
5864 hdaa_dump_amp(devinfo->dev, w->param.outamp_cap, "Output");
5865 if (HDA_PARAM_AUDIO_WIDGET_CAP_IN_AMP(w->param.widget_cap) &&
5866 w->param.inamp_cap != 0)
5867 hdaa_dump_amp(devinfo->dev, w->param.inamp_cap, " Input");
5868 if (w->nconns > 0)
5869 device_printf(devinfo->dev, " Connections: %d\n", w->nconns);
5870 for (j = 0; j < w->nconns; j++) {
5871 cw = hdaa_widget_get(devinfo, w->conns[j]);
5872 device_printf(devinfo->dev, " + %s<- nid=%d [%s]",
5873 (w->connsenable[j] == 0)?"[DISABLED] ":"",
5874 w->conns[j], (cw == NULL) ? "GHOST!" : cw->name);
5877 else if (cw->enable == 0)
5879 if (w->nconns > 1 && w->selconn == j && w->type !=
5891 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
5900 if (w == NULL || w->enable == 0)
5904 device_printf(pdevinfo->dev, "%*s", 4, "");
5906 device_printf(pdevinfo->dev, "%*s + <- ", 4 + (depth - 1) * 7, "");
5907 printf("nid=%d [%s]", w->nid, w->name);
5910 if (w->ossmask == 0) {
5916 w->ossmask, buf, sizeof(buf)));
5917 if (w->ossdev >= 0) {
5924 for (i = 0; i < w->nconns; i++) {
5925 if (w->connsenable[i] == 0)
5927 cw = hdaa_widget_get(devinfo, w->conns[i]);
5928 if (cw == NULL || cw->enable == 0 || cw->bindas == -1)
5930 hdaa_dump_dst_nid(pdevinfo, w->conns[i], depth + 1);
5938 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
5944 if (pdevinfo->playas < 0)
5947 device_printf(pdevinfo->dev, "Playback:\n");
5949 chid = devinfo->as[pdevinfo->playas].chans[0];
5950 hdaa_dump_audio_formats(pdevinfo->dev,
5951 devinfo->chans[chid].supp_stream_formats,
5952 devinfo->chans[chid].supp_pcm_size_rate);
5953 for (i = 0; i < devinfo->as[pdevinfo->playas].num_chans; i++) {
5954 chid = devinfo->as[pdevinfo->playas].chans[i];
5955 device_printf(pdevinfo->dev, " DAC:");
5956 for (nids = devinfo->chans[chid].io; *nids != -1; nids++)
5961 as = &devinfo->as[pdevinfo->playas];
5963 if (as->pins[i] <= 0)
5965 w = hdaa_widget_get(devinfo, as->pins[i]);
5966 if (w == NULL || w->enable == 0)
5968 device_printf(pdevinfo->dev, "\n");
5969 hdaa_dump_dst_nid(pdevinfo, as->pins[i], 0);
5971 device_printf(pdevinfo->dev, "\n");
5977 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
5982 if (pdevinfo->recas < 0)
5985 device_printf(pdevinfo->dev, "Record:\n");
5987 chid = devinfo->as[pdevinfo->recas].chans[0];
5988 hdaa_dump_audio_formats(pdevinfo->dev,
5989 devinfo->chans[chid].supp_stream_formats,
5990 devinfo->chans[chid].supp_pcm_size_rate);
5991 for (i = 0; i < devinfo->as[pdevinfo->recas].num_chans; i++) {
5992 chid = devinfo->as[pdevinfo->recas].chans[i];
5993 device_printf(pdevinfo->dev, " ADC:");
5994 for (nids = devinfo->chans[chid].io; *nids != -1; nids++)
5999 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
6001 if (w == NULL || w->enable == 0)
6003 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT)
6005 if (w->bindas != pdevinfo->recas)
6007 device_printf(pdevinfo->dev, "\n");
6010 device_printf(pdevinfo->dev, "\n");
6016 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
6021 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
6023 if (w == NULL || w->enable == 0)
6025 if (w->ossdev != SOUND_MIXER_IMIX)
6027 if (w->bindas != pdevinfo->recas)
6031 device_printf(pdevinfo->dev, "Input Mix:\n");
6033 device_printf(pdevinfo->dev, "\n");
6037 device_printf(pdevinfo->dev, "\n");
6051 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
6053 if (w == NULL || w->type !=
6056 hdaa_dump_pin_config(w, w->wclass.pin.config);
6057 pincap = w->wclass.pin.cap;
6069 HDA_CMD_SET_PIN_SENSE(0, w->nid, 0));
6072 HDA_CMD_GET_PIN_SENSE(0, w->nid));
6080 w->nid));
6085 (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap) &&
6095 HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap),
6096 HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap),
6097 HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap),
6098 HDA_PARAM_GPIO_COUNT_GPI_WAKE(devinfo->gpio_cap),
6099 HDA_PARAM_GPIO_COUNT_GPI_UNSOL(devinfo->gpio_cap));
6113 device_printf(dev, "Applying built-in patches...\n");
6193 device_printf(dev, "Applying direct built-in patches...\n");
6206 if (devinfo->quirks != 0) {
6209 if ((devinfo->quirks &
6220 device_printf(dev, "+-----------+\n");
6222 device_printf(dev, "+-----------+\n");
6226 device_printf(dev, "+----------------+\n");
6228 device_printf(dev, "+----------------+\n");
6233 (ctl->widget != NULL) ? ctl->widget->nid : -1,
6234 (ctl->ndir == HDAA_CTL_IN)?"in ":"out",
6235 (ctl->dir == HDAA_CTL_IN)?"in ":"out",
6236 ctl->index);
6237 if (ctl->childwidget != NULL)
6238 printf(" cnid %3d", ctl->childwidget->nid);
6242 ctl->ossmask);
6245 ctl->mute, ctl->step, ctl->size, ctl->offset,
6246 (ctl->enable == 0) ? " [DISABLED]" :
6247 ((ctl->ossmask == 0) ? " [UNUSED]" : ""));
6264 free(devinfo->ctl, M_HDAA);
6265 devinfo->ctl = NULL;
6266 devinfo->ctlcnt = 0;
6267 free(devinfo->as, M_HDAA);
6268 devinfo->as = NULL;
6269 devinfo->ascnt = 0;
6270 free(devinfo->devs, M_HDAA);
6271 devinfo->devs = NULL;
6272 devinfo->num_devs = 0;
6273 free(devinfo->chans, M_HDAA);
6274 devinfo->chans = NULL;
6275 devinfo->num_chans = 0;
6276 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
6280 w->enable = 1;
6281 w->selconn = -1;
6282 w->pflags = 0;
6283 w->bindas = -1;
6284 w->bindseqmask = 0;
6285 w->ossdev = -1;
6286 w->ossmask = 0;
6287 for (j = 0; j < w->nconns; j++)
6288 w->connsenable[j] = 1;
6289 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
6290 w->wclass.pin.config = w->wclass.pin.newconf;
6291 if (w->eld != NULL) {
6292 w->eld_len = 0;
6293 free(w->eld, M_HDAA);
6294 w->eld = NULL;
6302 struct hdaa_devinfo *devinfo = oidp->oid_arg1;
6303 device_t dev = devinfo->dev;
6310 numgpi = HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap);
6313 HDA_CMD_GET_GPI_DATA(0, devinfo->nid));
6317 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=%d",
6326 struct hdaa_devinfo *devinfo = oidp->oid_arg1;
6327 device_t dev = devinfo->dev;
6334 numgpio = HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap);
6337 HDA_CMD_GET_GPIO_DATA(0, devinfo->nid));
6339 HDA_CMD_GET_GPIO_ENABLE_MASK(0, devinfo->nid));
6341 HDA_CMD_GET_GPIO_DIRECTION(0, devinfo->nid));
6345 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=",
6348 n += snprintf(buf + n, sizeof(buf) - n, "disabled");
6351 n += snprintf(buf + n, sizeof(buf) - n, "%sput(%d)",
6360 struct hdaa_devinfo *devinfo = oidp->oid_arg1;
6365 gpio = devinfo->newgpio;
6366 numgpio = HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap);
6370 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=%s",
6374 if (error != 0 || req->newptr == NULL)
6381 devinfo->newgpio = devinfo->gpio = gpio;
6390 struct hdaa_devinfo *devinfo = oidp->oid_arg1;
6391 device_t dev = devinfo->dev;
6398 numgpo = HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap);
6401 HDA_CMD_GET_GPO_DATA(0, devinfo->nid));
6405 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=%d",
6414 struct hdaa_devinfo *devinfo = oidp->oid_arg1;
6419 gpo = devinfo->newgpo;
6420 numgpo = HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap);
6424 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=%s",
6428 if (error != 0 || req->newptr == NULL)
6435 devinfo->newgpo = devinfo->gpo = gpo;
6448 dev = oidp->oid_arg1;
6454 if (error != 0 || req->newptr == NULL || val == 0)
6494 for (i = 0; i < devinfo->num_chans; i++) {
6495 if (devinfo->chans[i].flags & HDAA_CHN_RUNNING) {
6496 devinfo->chans[i].flags |= HDAA_CHN_SUSPEND;
6497 hdaa_channel_stop(&devinfo->chans[i]);
6503 devinfo->nid);
6505 hda_command(devinfo->dev,
6507 devinfo->nid, HDA_CMD_POWER_STATE_D3));
6508 callout_stop(&devinfo->poll_jack);
6510 callout_drain(&devinfo->poll_jack);
6529 devinfo->nid);
6537 device_printf(dev, "Applying direct built-in patches...\n");
6546 for (i = 0; i < devinfo->num_devs; i++) {
6547 struct hdaa_pcm_devinfo *pdevinfo = &devinfo->devs[i];
6549 device_printf(pdevinfo->dev,
6552 if (mixer_reinit(pdevinfo->dev) == -1)
6553 device_printf(pdevinfo->dev,
6560 for (i = 0; i < devinfo->num_chans; i++) {
6561 if (devinfo->chans[i].flags & HDAA_CHN_SUSPEND) {
6562 devinfo->chans[i].flags &= ~HDAA_CHN_SUSPEND;
6563 hdaa_channel_start(&devinfo->chans[i]);
6582 (int)(strlen(pdesc) - 10), pdesc);
6593 devinfo->dev = dev;
6594 devinfo->lock = HDAC_GET_MTX(device_get_parent(dev), dev);
6595 devinfo->nid = nid;
6596 devinfo->newquirks = -1;
6597 devinfo->newgpio = -1;
6598 devinfo->newgpo = -1;
6599 callout_init(&devinfo->poll_jack, 1);
6600 devinfo->poll_ival = hz;
6607 devinfo->nodecnt = HDA_PARAM_SUB_NODE_COUNT_TOTAL(res);
6608 devinfo->startnode = HDA_PARAM_SUB_NODE_COUNT_START(res);
6609 devinfo->endnode = devinfo->startnode + devinfo->nodecnt;
6617 "Audio Function Group at nid=%d: %d subnodes %d-%d\n",
6618 nid, devinfo->nodecnt,
6619 devinfo->startnode, devinfo->endnode - 1);
6622 if (devinfo->nodecnt > 0)
6623 devinfo->widget = malloc(sizeof(*(devinfo->widget)) *
6624 devinfo->nodecnt, M_HDAA, M_WAITOK | M_ZERO);
6626 devinfo->widget = NULL;
6647 &devinfo->newquirks, 0, hdaa_sysctl_quirks, "A",
6676 &devinfo->init_clear, 1,"Clear initial pin widget configuration");
6692 devinfo->poll_ival = 0;
6693 callout_stop(&devinfo->poll_jack);
6695 callout_drain(&devinfo->poll_jack);
6697 free(devinfo->widget, M_HDAA);
6712 if (pdevinfo->playas >= 0) {
6713 as = &devinfo->as[pdevinfo->playas];
6715 if (as->pins[i] <= 0)
6717 retval += printf("%s%d", first ? "" : ",", as->pins[i]);
6721 if (pdevinfo->recas >= 0) {
6722 if (pdevinfo->playas >= 0) {
6726 as = &devinfo->as[pdevinfo->recas];
6728 if (as->pins[i] <= 0)
6730 retval += printf("%s%d", first ? "" : ",", as->pins[i]);
6749 if (pdevinfo->playas >= 0) {
6750 as = &devinfo->as[pdevinfo->playas];
6752 if (as->pins[i] <= 0)
6754 sbuf_printf(sb, "%s%d", first ? "" : ",", as->pins[i]);
6758 if (pdevinfo->recas >= 0) {
6759 as = &devinfo->as[pdevinfo->recas];
6761 if (as->pins[i] <= 0)
6763 sbuf_printf(sb, "%s%d", first ? "" : ",", as->pins[i]);
6777 for (i = 0; i < devinfo->num_chans; i++) {
6778 ch = &devinfo->chans[i];
6779 if (!(ch->flags & HDAA_CHN_RUNNING))
6781 if (ch->dir == ((dir == 1) ? PCMDIR_PLAY : PCMDIR_REC) &&
6782 ch->sid == stream) {
6784 chn_intr(ch->c);
6801 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
6803 if (w == NULL || w->enable == 0 || w->type !=
6806 if (w->unsol != tag)
6808 if (HDA_PARAM_PIN_CAP_DP(w->wclass.pin.cap) ||
6809 HDA_PARAM_PIN_CAP_HDMI(w->wclass.pin.cap))
6851 as = &devinfo->as[asid];
6852 c = devinfo->chans[as->chans[0]].channels;
6856 if (as->hpredir < 0)
6860 } else if (as->pinset == 0x0003)
6862 else if (as->pinset == 0x0005 || as->pinset == 0x0011)
6864 else if (as->pinset == 0x0007 || as->pinset == 0x0013)
6866 else if (as->pinset == 0x0017)
6870 if (as->hpredir >= 0)
6879 int i, t = -1, t1;
6881 as = &devinfo->as[asid];
6883 w = hdaa_widget_get(devinfo, as->pins[i]);
6884 if (w == NULL || w->enable == 0 || w->type !=
6887 t1 = HDA_CONFIG_DEFAULTCONF_DEVICE(w->wclass.pin.config);
6888 if (t == -1)
6891 t = -2;
6901 struct hdaa_audio_as *as = (struct hdaa_audio_as *)oidp->oid_arg1;
6902 struct hdaa_pcm_devinfo *pdevinfo = as->pdevinfo;
6903 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
6908 ch = &devinfo->chans[as->chans[0]];
6909 val = (ch->bit32 == 4) ? 32 : ((ch->bit32 == 3) ? 24 :
6910 ((ch->bit32 == 2) ? 20 : 0));
6912 if (error != 0 || req->newptr == NULL)
6914 pcmcap = ch->supp_pcm_size_rate;
6916 ch->bit32 = 4;
6918 ch->bit32 = 3;
6920 ch->bit32 = 2;
6923 for (i = 1; i < as->num_chans; i++)
6924 devinfo->chans[as->chans[i]].bit32 = ch->bit32;
6933 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
6938 if (pdevinfo->playas >= 0)
6939 loc1 = devinfo->as[pdevinfo->playas].location;
6941 loc1 = devinfo->as[pdevinfo->recas].location;
6942 if (pdevinfo->recas >= 0)
6943 loc2 = devinfo->as[pdevinfo->recas].location;
6947 loc1 = -2;
6949 loc1 = -2;
6952 t1 = t2 = -1;
6953 if (pdevinfo->playas >= 0) {
6954 hdaa_chan_formula(devinfo, pdevinfo->playas,
6956 t1 = hdaa_chan_type(devinfo, pdevinfo->playas);
6958 if (pdevinfo->recas >= 0) {
6959 hdaa_chan_formula(devinfo, pdevinfo->recas,
6961 t2 = hdaa_chan_type(devinfo, pdevinfo->recas);
6964 if (chans1[0] == 0 && pdevinfo->playas >= 0)
6966 else if (chans2[0] == 0 && pdevinfo->recas >= 0)
6971 if (t1 == -1)
6973 else if (t2 == -1)
6976 t1 = -2;
6977 if (pdevinfo->digital)
6978 t1 = -2;
6981 (int)(strlen(pdesc) - 21), pdesc,
6983 (pdevinfo->digital == 0x7)?"HDMI/DP":
6984 ((pdevinfo->digital == 0x5)?"DisplayPort":
6985 ((pdevinfo->digital == 0x3)?"HDMI":
6986 ((pdevinfo->digital)?"Digital":"Analog"))),
6998 struct hdaa_devinfo *devinfo = pdevinfo->devinfo;
7004 pdevinfo->chan_size = pcm_getbuffersize(dev,
7016 hdaa_dump_ctls(pdevinfo, "Line-in Volume", SOUND_MASK_LINE);
7029 pdevinfo->chan_blkcnt = pdevinfo->chan_size / i;
7031 while (pdevinfo->chan_blkcnt >> i)
7033 pdevinfo->chan_blkcnt = 1 << (i - 1);
7034 if (pdevinfo->chan_blkcnt < HDA_BDL_MIN)
7035 pdevinfo->chan_blkcnt = HDA_BDL_MIN;
7036 else if (pdevinfo->chan_blkcnt > HDA_BDL_MAX)
7037 pdevinfo->chan_blkcnt = HDA_BDL_MAX;
7039 pdevinfo->chan_blkcnt = HDA_BDL_DEFAULT;
7058 pdevinfo->registered++;
7061 if (pdevinfo->playas >= 0) {
7062 as = &devinfo->as[pdevinfo->playas];
7063 for (i = 0; i < as->num_chans; i++)
7065 &devinfo->chans[as->chans[i]]);
7066 SYSCTL_ADD_PROC(&d->play_sysctl_ctx,
7067 SYSCTL_CHILDREN(d->play_sysctl_tree), OID_AUTO,
7072 if (pdevinfo->recas >= 0) {
7073 as = &devinfo->as[pdevinfo->recas];
7074 for (i = 0; i < as->num_chans; i++)
7076 &devinfo->chans[as->chans[i]]);
7077 SYSCTL_ADD_PROC(&d->rec_sysctl_ctx,
7078 SYSCTL_CHILDREN(d->rec_sysctl_tree), OID_AUTO,
7082 pdevinfo->autorecsrc = 2;
7084 "rec.autosrc", &pdevinfo->autorecsrc);
7085 SYSCTL_ADD_INT(&d->rec_sysctl_ctx,
7086 SYSCTL_CHILDREN(d->rec_sysctl_tree), OID_AUTO,
7088 &pdevinfo->autorecsrc, 0,
7092 if (pdevinfo->mixer != NULL) {
7095 if (pdevinfo->playas >= 0) {
7096 as = &devinfo->as[pdevinfo->playas];
7099 if (pdevinfo->recas >= 0) {
7100 as = &devinfo->as[pdevinfo->recas];
7120 if (pdevinfo->registered > 0) {