Lines Matching +full:dsp +full:- +full:ctrl

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 || in hdaa_audio_ctl_each()
203 devinfo->ctlcnt < 1 || in hdaa_audio_ctl_each()
204 *index < 0 || *index >= devinfo->ctlcnt) in hdaa_audio_ctl_each()
206 return (&devinfo->ctl[(*index)++]); in hdaa_audio_ctl_each()
216 if (devinfo == NULL || devinfo->ctl == NULL) in hdaa_audio_ctl_amp_get()
221 if (ctl->enable == 0) in hdaa_audio_ctl_amp_get()
223 if (ctl->widget->nid != nid) in hdaa_audio_ctl_amp_get()
225 if (dir && ctl->ndir != dir) in hdaa_audio_ctl_amp_get()
227 if (index >= 0 && ctl->ndir == HDAA_CTL_IN && in hdaa_audio_ctl_amp_get()
228 ctl->dir == ctl->ndir && ctl->index != index) in hdaa_audio_ctl_amp_get()
265 struct hdaa_pcm_devinfo *pdevinfo = as->pdevinfo; in hdaa_channels_handler()
266 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_channels_handler()
267 struct hdaa_chan *ch = &devinfo->chans[as->chans[0]]; in hdaa_channels_handler()
277 if (as->pins[i] <= 0) in hdaa_channels_handler()
279 w = hdaa_widget_get(devinfo, as->pins[i]); in hdaa_channels_handler()
282 if (w->wclass.pin.connected == 1) in hdaa_channels_handler()
284 else if (w->wclass.pin.connected != 0) in hdaa_channels_handler()
286 if (w->eld != NULL && w->eld_len >= 8) in hdaa_channels_handler()
287 eld = w->eld; in hdaa_channels_handler()
290 if (as->hpredir >= 0) in hdaa_channels_handler()
293 tpins = as->pinset; in hdaa_channels_handler()
317 } else if (as->pinset != 0 && (tpins & 0xffe0) == 0) { in hdaa_channels_handler()
329 if ((as->pinset & 0x0004) == 0) in hdaa_channels_handler()
334 } else if (as->mixed) { in hdaa_channels_handler()
336 if (ch->channels == 1) in hdaa_channels_handler()
343 device_printf(pdevinfo->dev, "%s channel set is: ", in hdaa_channels_handler()
344 as->dir == HDAA_CTL_OUT ? "Playback" : "Recording"); in hdaa_channels_handler()
352 if (as->pinset != 0 && matrixes[i].analog == 0) in hdaa_channels_handler()
362 total = ch->channels; in hdaa_channels_handler()
366 device_printf(pdevinfo->dev, in hdaa_channels_handler()
368 as->dir == HDAA_CTL_OUT ? "Playback" : "Recording", in hdaa_channels_handler()
369 assume ? "unknown, assuming " : "", total - sub, sub, in hdaa_channels_handler()
381 struct hdaa_devinfo *devinfo = w->devinfo; in hdaa_hpredir_handler()
382 struct hdaa_audio_as *as = &devinfo->as[w->bindas]; in hdaa_hpredir_handler()
386 int j, connected = w->wclass.pin.connected; in hdaa_hpredir_handler()
389 device_printf((as->pdevinfo && as->pdevinfo->dev) ? in hdaa_hpredir_handler()
390 as->pdevinfo->dev : devinfo->dev, in hdaa_hpredir_handler()
396 w->nid, HDAA_CTL_IN, -1, 1); in hdaa_hpredir_handler()
397 if (ctl != NULL && ctl->mute) { in hdaa_hpredir_handler()
398 /* If pin has muter - use it. */ in hdaa_hpredir_handler()
400 if (val != ctl->forcemute) { in hdaa_hpredir_handler()
401 ctl->forcemute = val; in hdaa_hpredir_handler()
407 /* If there is no muter - disable pin output. */ in hdaa_hpredir_handler()
409 val = w->wclass.pin.ctrl | in hdaa_hpredir_handler()
412 val = w->wclass.pin.ctrl & in hdaa_hpredir_handler()
414 if (val != w->wclass.pin.ctrl) { in hdaa_hpredir_handler()
415 w->wclass.pin.ctrl = val; in hdaa_hpredir_handler()
416 hda_command(devinfo->dev, in hdaa_hpredir_handler()
418 w->nid, w->wclass.pin.ctrl)); in hdaa_hpredir_handler()
423 if (as->pins[j] <= 0) in hdaa_hpredir_handler()
426 as->pins[j], HDAA_CTL_IN, -1, 1); in hdaa_hpredir_handler()
427 if (ctl != NULL && ctl->mute) { in hdaa_hpredir_handler()
428 /* If pin has muter - use it. */ in hdaa_hpredir_handler()
430 if (val == ctl->forcemute) in hdaa_hpredir_handler()
432 ctl->forcemute = val; in hdaa_hpredir_handler()
438 /* If there is no muter - disable pin output. */ in hdaa_hpredir_handler()
439 w1 = hdaa_widget_get(devinfo, as->pins[j]); in hdaa_hpredir_handler()
442 val = w1->wclass.pin.ctrl & in hdaa_hpredir_handler()
445 val = w1->wclass.pin.ctrl | in hdaa_hpredir_handler()
447 if (val != w1->wclass.pin.ctrl) { in hdaa_hpredir_handler()
448 w1->wclass.pin.ctrl = val; in hdaa_hpredir_handler()
449 hda_command(devinfo->dev, in hdaa_hpredir_handler()
451 w1->nid, w1->wclass.pin.ctrl)); in hdaa_hpredir_handler()
463 struct hdaa_pcm_devinfo *pdevinfo = as->pdevinfo; in hdaa_autorecsrc_handler()
469 if (!as->mixed || pdevinfo == NULL || pdevinfo->mixer == NULL) in hdaa_autorecsrc_handler()
472 if (pdevinfo->autorecsrc == 0 || in hdaa_autorecsrc_handler()
473 (pdevinfo->autorecsrc == 1 && w != NULL)) in hdaa_autorecsrc_handler()
476 if (pdevinfo->recsrc & (SOUND_MASK_IMIX | SOUND_MASK_SPEAKER)) in hdaa_autorecsrc_handler()
479 if (ffs(pdevinfo->recsrc) != fls(pdevinfo->recsrc)) in hdaa_autorecsrc_handler()
481 devinfo = pdevinfo->devinfo; in hdaa_autorecsrc_handler()
485 if (as->pins[i] <= 0) in hdaa_autorecsrc_handler()
487 w1 = hdaa_widget_get(devinfo, as->pins[i]); in hdaa_autorecsrc_handler()
488 if (w1 == NULL || w1->enable == 0) in hdaa_autorecsrc_handler()
490 if (w1->wclass.pin.connected == 0) in hdaa_autorecsrc_handler()
492 prio = (w1->wclass.pin.connected == 1) ? 2 : 1; in hdaa_autorecsrc_handler()
499 mask |= (1 << w1->ossdev); in hdaa_autorecsrc_handler()
500 fullmask |= (1 << w1->ossdev); in hdaa_autorecsrc_handler()
505 if (w != NULL && (mask & (1 << w->ossdev))) in hdaa_autorecsrc_handler()
506 mask = (1 << w->ossdev); in hdaa_autorecsrc_handler()
508 if (mask & pdevinfo->recsrc) in hdaa_autorecsrc_handler()
509 mask &= pdevinfo->recsrc; in hdaa_autorecsrc_handler()
517 mask = (1 << (ffs(mask) - 1)); in hdaa_autorecsrc_handler()
520 device_printf(pdevinfo->dev, in hdaa_autorecsrc_handler()
524 mix_setrecsrc(pdevinfo->mixer, mask); in hdaa_autorecsrc_handler()
534 struct hdaa_devinfo *devinfo = w->devinfo; in hdaa_presence_handler()
541 if (w->enable == 0 || w->type != in hdaa_presence_handler()
545 if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(w->wclass.pin.cap) == 0 || in hdaa_presence_handler()
546 (HDA_CONFIG_DEFAULTCONF_MISC(w->wclass.pin.config) & 1) != 0) in hdaa_presence_handler()
549 res = hda_command(devinfo->dev, HDA_CMD_GET_PIN_SENSE(0, w->nid)); in hdaa_presence_handler()
551 if (devinfo->quirks & HDAA_QUIRK_SENSEINV) in hdaa_presence_handler()
553 old = w->wclass.pin.connected; in hdaa_presence_handler()
556 w->wclass.pin.connected = connected; in hdaa_presence_handler()
558 as = &devinfo->as[w->bindas]; in hdaa_presence_handler()
559 if (as->hpredir >= 0 && as->pins[15] == w->nid) in hdaa_presence_handler()
561 if (as->dir == HDAA_CTL_IN && old != 2) in hdaa_presence_handler()
568 device_printf(devinfo->dev, in hdaa_presence_handler()
570 w->nid, res, !connected ? "dis" : ""); in hdaa_presence_handler()
572 if (as->hpredir >= 0) in hdaa_presence_handler()
574 for (i = 0, active = false; i < devinfo->num_devs; i++) { in hdaa_presence_handler()
575 if (device_get_unit(devinfo->devs[i].dev) == snd_unit) { in hdaa_presence_handler()
583 for (i = 0; i < devinfo->ascnt; i++) { in hdaa_presence_handler()
584 asp = &devinfo->as[i]; in hdaa_presence_handler()
585 if (!asp->enable) in hdaa_presence_handler()
587 if ((connected && asp->index == as->index) || in hdaa_presence_handler()
588 (!connected && asp->dir == as->dir)) { in hdaa_presence_handler()
589 snprintf(buf, sizeof(buf), "cdev=dsp%d", in hdaa_presence_handler()
590 device_get_unit(asp->pdevinfo->dev)); in hdaa_presence_handler()
592 asp->dir == HDAA_CTL_IN ? "IN" : "OUT", buf); in hdaa_presence_handler()
610 if (devinfo->poll_ival == 0) { in hdaa_jack_poll_callback()
614 for (i = 0; i < devinfo->ascnt; i++) { in hdaa_jack_poll_callback()
615 if (devinfo->as[i].hpredir < 0) in hdaa_jack_poll_callback()
617 w = hdaa_widget_get(devinfo, devinfo->as[i].pins[15]); in hdaa_jack_poll_callback()
618 if (w == NULL || w->enable == 0 || w->type != in hdaa_jack_poll_callback()
623 callout_reset(&devinfo->poll_jack, devinfo->poll_ival, in hdaa_jack_poll_callback()
631 struct hdaa_devinfo *devinfo = w->devinfo; in hdaa_eld_dump()
632 device_t dev = devinfo->dev; in hdaa_eld_dump()
636 if (w->eld == NULL || w->eld_len < 4) in hdaa_eld_dump()
640 w->nid, w->eld[0] >> 3, w->eld[2]); in hdaa_eld_dump()
641 if ((w->eld[0] >> 3) != 0x02) in hdaa_eld_dump()
643 mnl = w->eld[4] & 0x1f; in hdaa_eld_dump()
646 w->nid, w->eld[4] >> 5, mnl); in hdaa_eld_dump()
647 sadc = w->eld[5] >> 4; in hdaa_eld_dump()
650 w->nid, sadc, (w->eld[5] >> 2) & 0x3, in hdaa_eld_dump()
651 (w->eld[5] >> 1) & 0x1, w->eld[5] & 0x1); in hdaa_eld_dump()
654 w->nid, w->eld[6] * 2); in hdaa_eld_dump()
657 w->nid, w->eld[7], in hdaa_eld_dump()
661 w->nid, w->eld[8], w->eld[9], w->eld[10], w->eld[11], in hdaa_eld_dump()
662 w->eld[12], w->eld[13], w->eld[14], w->eld[15]); in hdaa_eld_dump()
665 w->nid, w->eld[16], w->eld[17]); in hdaa_eld_dump()
668 w->nid, w->eld[18], w->eld[19]); in hdaa_eld_dump()
671 w->nid, mnl, &w->eld[20]); in hdaa_eld_dump()
673 sad = &w->eld[20 + mnl + i * 3]; in hdaa_eld_dump()
684 w->nid, HDA_HDMI_CODING_TYPES[fmt], (sad[0] & 0x07) + 1, in hdaa_eld_dump()
711 struct hdaa_devinfo *devinfo = w->devinfo; in hdaa_eld_handler()
715 if (w->enable == 0 || w->type != in hdaa_eld_handler()
719 if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(w->wclass.pin.cap) == 0 || in hdaa_eld_handler()
720 (HDA_CONFIG_DEFAULTCONF_MISC(w->wclass.pin.config) & 1) != 0) in hdaa_eld_handler()
723 res = hda_command(devinfo->dev, HDA_CMD_GET_PIN_SENSE(0, w->nid)); in hdaa_eld_handler()
724 if ((w->eld != 0) == ((res & HDA_CMD_GET_PIN_SENSE_ELD_VALID) != 0)) in hdaa_eld_handler()
726 if (w->eld != NULL) { in hdaa_eld_handler()
727 w->eld_len = 0; in hdaa_eld_handler()
728 free(w->eld, M_HDAA); in hdaa_eld_handler()
729 w->eld = NULL; in hdaa_eld_handler()
732 device_printf(devinfo->dev, in hdaa_eld_handler()
735 w->nid, res, in hdaa_eld_handler()
742 res = hda_command(devinfo->dev, in hdaa_eld_handler()
743 HDA_CMD_GET_HDMI_DIP_SIZE(0, w->nid, 0x08)); in hdaa_eld_handler()
746 w->eld_len = res & 0xff; in hdaa_eld_handler()
747 if (w->eld_len != 0) in hdaa_eld_handler()
748 w->eld = malloc(w->eld_len, M_HDAA, M_ZERO | M_NOWAIT); in hdaa_eld_handler()
749 if (w->eld == NULL) { in hdaa_eld_handler()
750 w->eld_len = 0; in hdaa_eld_handler()
754 for (i = 0; i < w->eld_len; i++) { in hdaa_eld_handler()
755 res = hda_command(devinfo->dev, in hdaa_eld_handler()
756 HDA_CMD_GET_HDMI_ELDD(0, w->nid, i)); in hdaa_eld_handler()
758 w->eld[i] = res & 0xff; in hdaa_eld_handler()
763 hdaa_channels_handler(&devinfo->as[w->bindas]); in hdaa_eld_handler()
776 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_sense_init()
778 if (w == NULL || w->enable == 0 || w->type != in hdaa_sense_init()
781 if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(w->param.widget_cap)) { in hdaa_sense_init()
782 if (w->unsol < 0) in hdaa_sense_init()
783 w->unsol = HDAC_UNSOL_ALLOC( in hdaa_sense_init()
784 device_get_parent(devinfo->dev), in hdaa_sense_init()
785 devinfo->dev, w->nid); in hdaa_sense_init()
786 hda_command(devinfo->dev, in hdaa_sense_init()
787 HDA_CMD_SET_UNSOLICITED_RESPONSE(0, w->nid, in hdaa_sense_init()
788 HDA_CMD_SET_UNSOLICITED_RESPONSE_ENABLE | w->unsol)); in hdaa_sense_init()
790 as = &devinfo->as[w->bindas]; in hdaa_sense_init()
791 if (as->hpredir >= 0 && as->pins[15] == w->nid) { in hdaa_sense_init()
792 if (HDA_PARAM_PIN_CAP_PRESENCE_DETECT_CAP(w->wclass.pin.cap) == 0 || in hdaa_sense_init()
793 (HDA_CONFIG_DEFAULTCONF_MISC(w->wclass.pin.config) & 1) != 0) { in hdaa_sense_init()
794 device_printf(devinfo->dev, in hdaa_sense_init()
796 w->nid); in hdaa_sense_init()
798 if (w->unsol < 0) in hdaa_sense_init()
801 device_printf(devinfo->dev, in hdaa_sense_init()
804 w->bindas, w->nid, in hdaa_sense_init()
805 (w->unsol < 0) ? "polling" : in hdaa_sense_init()
811 if (!HDA_PARAM_PIN_CAP_DP(w->wclass.pin.cap) && in hdaa_sense_init()
812 !HDA_PARAM_PIN_CAP_HDMI(w->wclass.pin.cap)) in hdaa_sense_init()
817 callout_reset(&devinfo->poll_jack, 1, in hdaa_sense_init()
828 callout_stop(&devinfo->poll_jack); in hdaa_sense_deinit()
829 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_sense_deinit()
831 if (w == NULL || w->enable == 0 || w->type != in hdaa_sense_deinit()
834 if (w->unsol < 0) in hdaa_sense_deinit()
836 hda_command(devinfo->dev, in hdaa_sense_deinit()
837 HDA_CMD_SET_UNSOLICITED_RESPONSE(0, w->nid, 0)); in hdaa_sense_deinit()
839 device_get_parent(devinfo->dev), devinfo->dev, in hdaa_sense_deinit()
840 w->unsol); in hdaa_sense_deinit()
841 w->unsol = -1; in hdaa_sense_deinit()
969 device_t dev = w->devinfo->dev; in hdaa_local_patch_pin()
974 config = orig = w->wclass.pin.config; in hdaa_local_patch_pin()
976 hda_get_codec_id(dev), w->nid); in hdaa_local_patch_pin()
987 snprintf(buf, sizeof(buf), "nid%u.config", w->nid); in hdaa_local_patch_pin()
998 device_printf(w->devinfo->dev, in hdaa_local_patch_pin()
999 "Patching pin config nid=%u 0x%08x -> 0x%08x\n", in hdaa_local_patch_pin()
1000 w->nid, orig, config); in hdaa_local_patch_pin()
1002 w->wclass.pin.newconf = w->wclass.pin.config = config; in hdaa_local_patch_pin()
1065 pincap = w->wclass.pin.cap; in hdaa_dump_pin_sb()
1105 conf = w->wclass.pin.config; in hdaa_dump_pin_sb()
1117 sbuf_printf(sb, " Pin control: 0x%08x", w->wclass.pin.ctrl); in hdaa_dump_pin_sb()
1118 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE) in hdaa_dump_pin_sb()
1120 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE) in hdaa_dump_pin_sb()
1122 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_OUT_ENABLE) in hdaa_dump_pin_sb()
1124 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) { in hdaa_dump_pin_sb()
1125 if ((w->wclass.pin.ctrl & in hdaa_dump_pin_sb()
1128 else if ((w->wclass.pin.ctrl & in hdaa_dump_pin_sb()
1132 if ((w->wclass.pin.ctrl & in hdaa_dump_pin_sb()
1152 ((0 - offset) * (size + 1)) / 4, in hdaa_dump_amp_sb()
1153 ((step - offset) * (size + 1)) / 4); in hdaa_dump_amp_sb()
1165 w = (struct hdaa_widget *)oidp->oid_arg1; in hdaa_sysctl_caps()
1166 devinfo = w->devinfo; in hdaa_sysctl_caps()
1169 sbuf_printf(&sb, "%s%s\n", w->name, in hdaa_sysctl_caps()
1170 (w->enable == 0) ? " [DISABLED]" : ""); in hdaa_sysctl_caps()
1172 w->param.widget_cap); in hdaa_sysctl_caps()
1173 if (w->param.widget_cap & 0x0ee1) { in hdaa_sysctl_caps()
1174 if (HDA_PARAM_AUDIO_WIDGET_CAP_LR_SWAP(w->param.widget_cap)) in hdaa_sysctl_caps()
1176 if (HDA_PARAM_AUDIO_WIDGET_CAP_POWER_CTRL(w->param.widget_cap)) in hdaa_sysctl_caps()
1178 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) in hdaa_sysctl_caps()
1180 if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(w->param.widget_cap)) in hdaa_sysctl_caps()
1182 if (HDA_PARAM_AUDIO_WIDGET_CAP_PROC_WIDGET(w->param.widget_cap)) in hdaa_sysctl_caps()
1184 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap)) in hdaa_sysctl_caps()
1186 1 << (fls(w->wclass.conv.stripecap) - 1)); in hdaa_sysctl_caps()
1187 j = HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap); in hdaa_sysctl_caps()
1194 if (w->bindas != -1) { in hdaa_sysctl_caps()
1196 w->bindas, w->bindseqmask); in hdaa_sysctl_caps()
1198 if (w->ossmask != 0 || w->ossdev >= 0) { in hdaa_sysctl_caps()
1200 hdaa_audio_ctl_ossmixer_mask2allname(w->ossmask, buf, sizeof(buf))); in hdaa_sysctl_caps()
1201 if (w->ossdev >= 0) in hdaa_sysctl_caps()
1202 sbuf_printf(&sb, " (%s)", ossnames[w->ossdev]); in hdaa_sysctl_caps()
1205 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT || in hdaa_sysctl_caps()
1206 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) { in hdaa_sysctl_caps()
1208 w->param.supp_stream_formats, in hdaa_sysctl_caps()
1209 w->param.supp_pcm_size_rate); in hdaa_sysctl_caps()
1210 } else if (w->type == in hdaa_sysctl_caps()
1211 HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || w->waspin) in hdaa_sysctl_caps()
1213 if (w->param.eapdbtl != HDA_INVALID) { in hdaa_sysctl_caps()
1215 w->param.eapdbtl, in hdaa_sysctl_caps()
1216 (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_LR_SWAP) ? in hdaa_sysctl_caps()
1218 (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD) ? in hdaa_sysctl_caps()
1220 (w->param.eapdbtl & HDA_CMD_SET_EAPD_BTL_ENABLE_BTL) ? in hdaa_sysctl_caps()
1223 if (HDA_PARAM_AUDIO_WIDGET_CAP_OUT_AMP(w->param.widget_cap) && in hdaa_sysctl_caps()
1224 w->param.outamp_cap != 0) in hdaa_sysctl_caps()
1225 hdaa_dump_amp_sb(&sb, w->param.outamp_cap, "Output"); in hdaa_sysctl_caps()
1226 if (HDA_PARAM_AUDIO_WIDGET_CAP_IN_AMP(w->param.widget_cap) && in hdaa_sysctl_caps()
1227 w->param.inamp_cap != 0) in hdaa_sysctl_caps()
1228 hdaa_dump_amp_sb(&sb, w->param.inamp_cap, " Input"); in hdaa_sysctl_caps()
1229 if (w->nconns > 0) in hdaa_sysctl_caps()
1230 sbuf_printf(&sb, " Connections: %d\n", w->nconns); in hdaa_sysctl_caps()
1231 for (j = 0; j < w->nconns; j++) { in hdaa_sysctl_caps()
1232 cw = hdaa_widget_get(devinfo, w->conns[j]); in hdaa_sysctl_caps()
1233 sbuf_printf(&sb, " + %s<- nid=%d [%s]", in hdaa_sysctl_caps()
1234 (w->connsenable[j] == 0)?"[DISABLED] ":"", in hdaa_sysctl_caps()
1235 w->conns[j], (cw == NULL) ? "GHOST!" : cw->name); in hdaa_sysctl_caps()
1238 else if (cw->enable == 0) in hdaa_sysctl_caps()
1240 if (w->nconns > 1 && w->selconn == j && w->type != in hdaa_sysctl_caps()
1257 conf = *(uint32_t *)oidp->oid_arg1; in hdaa_sysctl_config()
1270 if (error != 0 || req->newptr == NULL) in hdaa_sysctl_config()
1276 *(uint32_t *)oidp->oid_arg1 = conf; in hdaa_sysctl_config()
1296 len = j - i; in hdaa_config_fetch()
1303 hdaa_quirks_tab[k].key, len - inv) != 0) in hdaa_config_fetch()
1305 if (len - inv != strlen(hdaa_quirks_tab[k].key)) in hdaa_config_fetch()
1328 quirks = *(uint32_t *)oidp->oid_arg1; in hdaa_sysctl_quirks()
1332 n += snprintf(buf + n, sizeof(buf) - n, "%s%s", in hdaa_sysctl_quirks()
1336 if (error != 0 || req->newptr == NULL) in hdaa_sysctl_quirks()
1344 *(uint32_t *)oidp->oid_arg1 = quirks; in hdaa_sysctl_quirks()
1356 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_local_patch()
1360 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_local_patch()
1364 if (resource_string_value(device_get_name(devinfo->dev), in hdaa_local_patch()
1365 device_get_unit(devinfo->dev), "config", &res) == 0) { in hdaa_local_patch()
1368 devinfo->quirks |= quirks_on; in hdaa_local_patch()
1369 devinfo->quirks &= ~quirks_off; in hdaa_local_patch()
1371 if (devinfo->newquirks == -1) in hdaa_local_patch()
1372 devinfo->newquirks = devinfo->quirks; in hdaa_local_patch()
1374 devinfo->quirks = devinfo->newquirks; in hdaa_local_patch()
1376 device_printf(devinfo->dev, in hdaa_local_patch()
1377 "Config options: 0x%08x\n", devinfo->quirks); in hdaa_local_patch()
1380 if (resource_string_value(device_get_name(devinfo->dev), in hdaa_local_patch()
1381 device_get_unit(devinfo->dev), "gpio_config", &res) == 0) { in hdaa_local_patch()
1383 devinfo->gpio = strtol(res + 2, NULL, 16); in hdaa_local_patch()
1385 devinfo->gpio = hdaa_gpio_patch(devinfo->gpio, res); in hdaa_local_patch()
1388 if (devinfo->newgpio == -1) in hdaa_local_patch()
1389 devinfo->newgpio = devinfo->gpio; in hdaa_local_patch()
1391 devinfo->gpio = devinfo->newgpio; in hdaa_local_patch()
1392 if (devinfo->newgpo == -1) in hdaa_local_patch()
1393 devinfo->newgpo = devinfo->gpo; in hdaa_local_patch()
1395 devinfo->gpo = devinfo->newgpo; in hdaa_local_patch()
1397 device_printf(devinfo->dev, "GPIO config options:"); in hdaa_local_patch()
1399 x = (devinfo->gpio & HDAA_GPIO_MASK(i)) >> HDAA_GPIO_SHIFT(i); in hdaa_local_patch()
1412 nid_t nid = w->nid; in hdaa_widget_connection_parse()
1415 w->nconns = 0; in hdaa_widget_connection_parse()
1417 res = hda_command(w->devinfo->dev, in hdaa_widget_connection_parse()
1426 max = (sizeof(w->conns) / sizeof(w->conns[0])) - 1; in hdaa_widget_connection_parse()
1429 #define CONN_RMASK(e) (1 << ((32 / (e)) - 1)) in hdaa_widget_connection_parse()
1430 #define CONN_NMASK(e) (CONN_RMASK(e) - 1) in hdaa_widget_connection_parse()
1436 res = hda_command(w->devinfo->dev, in hdaa_widget_connection_parse()
1441 if (w->nconns < ents) in hdaa_widget_connection_parse()
1442 device_printf(w->devinfo->dev, in hdaa_widget_connection_parse()
1447 ents, w->nconns, res); in hdaa_widget_connection_parse()
1451 if (cnid < w->devinfo->startnode || in hdaa_widget_connection_parse()
1452 cnid >= w->devinfo->endnode) { in hdaa_widget_connection_parse()
1454 device_printf(w->devinfo->dev, in hdaa_widget_connection_parse()
1464 device_printf(w->devinfo->dev, in hdaa_widget_connection_parse()
1474 if (w->nconns > max) { in hdaa_widget_connection_parse()
1475 device_printf(w->devinfo->dev, in hdaa_widget_connection_parse()
1481 w->connsenable[w->nconns] = 1; in hdaa_widget_connection_parse()
1482 w->conns[w->nconns++] = addcnid++; in hdaa_widget_connection_parse()
1495 device_t dev = w->devinfo->dev; in hdaa_widget_parse()
1497 nid_t nid = w->nid; in hdaa_widget_parse()
1500 w->param.widget_cap = wcap = hda_command(dev, in hdaa_widget_parse()
1502 w->type = HDA_PARAM_AUDIO_WIDGET_CAP_TYPE(wcap); in hdaa_widget_parse()
1508 w->param.outamp_cap = in hdaa_widget_parse()
1513 w->param.outamp_cap = in hdaa_widget_parse()
1514 w->devinfo->outamp_cap; in hdaa_widget_parse()
1516 w->param.outamp_cap = 0; in hdaa_widget_parse()
1520 w->param.inamp_cap = in hdaa_widget_parse()
1525 w->param.inamp_cap = in hdaa_widget_parse()
1526 w->devinfo->inamp_cap; in hdaa_widget_parse()
1528 w->param.inamp_cap = 0; in hdaa_widget_parse()
1530 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT || in hdaa_widget_parse()
1531 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) { in hdaa_widget_parse()
1536 w->param.supp_stream_formats = (cap != 0) ? cap : in hdaa_widget_parse()
1537 w->devinfo->supp_stream_formats; in hdaa_widget_parse()
1541 w->param.supp_pcm_size_rate = (cap != 0) ? cap : in hdaa_widget_parse()
1542 w->devinfo->supp_pcm_size_rate; in hdaa_widget_parse()
1544 w->param.supp_stream_formats = in hdaa_widget_parse()
1545 w->devinfo->supp_stream_formats; in hdaa_widget_parse()
1546 w->param.supp_pcm_size_rate = in hdaa_widget_parse()
1547 w->devinfo->supp_pcm_size_rate; in hdaa_widget_parse()
1549 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap)) { in hdaa_widget_parse()
1550 w->wclass.conv.stripecap = hda_command(dev, in hdaa_widget_parse()
1551 HDA_CMD_GET_STRIPE_CONTROL(0, w->nid)) >> 20; in hdaa_widget_parse()
1553 w->wclass.conv.stripecap = 1; in hdaa_widget_parse()
1555 w->param.supp_stream_formats = 0; in hdaa_widget_parse()
1556 w->param.supp_pcm_size_rate = 0; in hdaa_widget_parse()
1559 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) { in hdaa_widget_parse()
1560 w->wclass.pin.original = w->wclass.pin.newconf = in hdaa_widget_parse()
1561 w->wclass.pin.config = hda_command(dev, in hdaa_widget_parse()
1562 HDA_CMD_GET_CONFIGURATION_DEFAULT(0, w->nid)); in hdaa_widget_parse()
1563 w->wclass.pin.cap = hda_command(dev, in hdaa_widget_parse()
1564 HDA_CMD_GET_PARAMETER(0, w->nid, HDA_PARAM_PIN_CAP)); in hdaa_widget_parse()
1565 w->wclass.pin.ctrl = hda_command(dev, in hdaa_widget_parse()
1567 w->wclass.pin.connected = 2; in hdaa_widget_parse()
1568 if (HDA_PARAM_PIN_CAP_EAPD_CAP(w->wclass.pin.cap)) { in hdaa_widget_parse()
1569 w->param.eapdbtl = hda_command(dev, in hdaa_widget_parse()
1571 w->param.eapdbtl &= 0x7; in hdaa_widget_parse()
1572 w->param.eapdbtl |= HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD; in hdaa_widget_parse()
1574 w->param.eapdbtl = HDA_INVALID; in hdaa_widget_parse()
1576 w->unsol = -1; in hdaa_widget_parse()
1578 hdaa_unlock(w->devinfo); in hdaa_widget_parse()
1579 snprintf(buf, sizeof(buf), "nid%d", w->nid); in hdaa_widget_parse()
1584 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) { in hdaa_widget_parse()
1585 snprintf(buf, sizeof(buf), "nid%d_config", w->nid); in hdaa_widget_parse()
1589 &w->wclass.pin.newconf, 0, hdaa_sysctl_config, "A", in hdaa_widget_parse()
1591 snprintf(buf, sizeof(buf), "nid%d_original", w->nid); in hdaa_widget_parse()
1595 &w->wclass.pin.original, 0, hdaa_sysctl_config, "A", in hdaa_widget_parse()
1598 hdaa_lock(w->devinfo); in hdaa_widget_parse()
1606 w->type = HDA_PARAM_AUDIO_WIDGET_CAP_TYPE(w->param.widget_cap); in hdaa_widget_postprocess()
1607 switch (w->type) { in hdaa_widget_postprocess()
1639 strlcpy(w->name, typestr, sizeof(w->name)); in hdaa_widget_postprocess()
1641 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) { in hdaa_widget_postprocess()
1646 config = w->wclass.pin.config; in hdaa_widget_postprocess()
1653 strlcat(w->name, ": ", sizeof(w->name)); in hdaa_widget_postprocess()
1654 strlcat(w->name, devstr, sizeof(w->name)); in hdaa_widget_postprocess()
1655 strlcat(w->name, " (", sizeof(w->name)); in hdaa_widget_postprocess()
1657 strlcat(w->name, HDA_COLORS[color], sizeof(w->name)); in hdaa_widget_postprocess()
1658 strlcat(w->name, " ", sizeof(w->name)); in hdaa_widget_postprocess()
1660 strlcat(w->name, HDA_CONNS[conn], sizeof(w->name)); in hdaa_widget_postprocess()
1661 strlcat(w->name, ")", sizeof(w->name)); in hdaa_widget_postprocess()
1668 if (devinfo == NULL || devinfo->widget == NULL || in hdaa_widget_get()
1669 nid < devinfo->startnode || nid >= devinfo->endnode) in hdaa_widget_get()
1671 return (&devinfo->widget[nid - devinfo->startnode]); in hdaa_widget_get()
1682 device_printf(devinfo->dev, in hdaa_audio_ctl_amp_set_internal()
1687 v = (1 << (15 - dir)) | (1 << 13) | (index << 8) | in hdaa_audio_ctl_amp_set_internal()
1689 hda_command(devinfo->dev, in hdaa_audio_ctl_amp_set_internal()
1691 v = (1 << (15 - dir)) | (1 << 12) | (index << 8) | in hdaa_audio_ctl_amp_set_internal()
1694 v = (1 << (15 - dir)) | (3 << 12) | (index << 8) | in hdaa_audio_ctl_amp_set_internal()
1697 hda_command(devinfo->dev, in hdaa_audio_ctl_amp_set_internal()
1708 nid = ctl->widget->nid; in hdaa_audio_ctl_amp_set()
1712 ctl->muted = mute; in hdaa_audio_ctl_amp_set()
1714 ctl->left = left; in hdaa_audio_ctl_amp_set()
1716 ctl->right = right; in hdaa_audio_ctl_amp_set()
1718 if (ctl->forcemute) { in hdaa_audio_ctl_amp_set()
1724 lmute = HDAA_AMP_LEFT_MUTED(ctl->muted); in hdaa_audio_ctl_amp_set()
1725 rmute = HDAA_AMP_RIGHT_MUTED(ctl->muted); in hdaa_audio_ctl_amp_set()
1726 left = ctl->left; in hdaa_audio_ctl_amp_set()
1727 right = ctl->right; in hdaa_audio_ctl_amp_set()
1730 if (ctl->dir & HDAA_CTL_OUT) in hdaa_audio_ctl_amp_set()
1731 hdaa_audio_ctl_amp_set_internal(ctl->widget->devinfo, nid, ctl->index, in hdaa_audio_ctl_amp_set()
1733 if (ctl->dir & HDAA_CTL_IN) in hdaa_audio_ctl_amp_set()
1734 hdaa_audio_ctl_amp_set_internal(ctl->widget->devinfo, nid, ctl->index, in hdaa_audio_ctl_amp_set()
1741 if (w == NULL || w->nconns < 1 || index > (w->nconns - 1)) in hdaa_widget_connection_select()
1744 device_printf(w->devinfo->dev, in hdaa_widget_connection_select()
1745 "Setting selector nid=%d index=%d\n", w->nid, index); in hdaa_widget_connection_select()
1747 hda_command(w->devinfo->dev, in hdaa_widget_connection_select()
1748 HDA_CMD_SET_CONNECTION_SELECT_CONTROL(0, w->nid, index)); in hdaa_widget_connection_select()
1749 w->selconn = index; in hdaa_widget_connection_select()
1761 struct hdaa_pcm_devinfo *pdevinfo = ch->pdevinfo; in hdaa_channel_init()
1762 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_channel_init()
1765 if (devinfo->quirks & HDAA_QUIRK_FIXEDRATE) { in hdaa_channel_init()
1766 ch->caps.minspeed = ch->caps.maxspeed = 48000; in hdaa_channel_init()
1767 ch->pcmrates[0] = 48000; in hdaa_channel_init()
1768 ch->pcmrates[1] = 0; in hdaa_channel_init()
1770 ch->dir = dir; in hdaa_channel_init()
1771 ch->b = b; in hdaa_channel_init()
1772 ch->c = c; in hdaa_channel_init()
1773 ch->blksz = pdevinfo->chan_size / pdevinfo->chan_blkcnt; in hdaa_channel_init()
1774 ch->blkcnt = pdevinfo->chan_blkcnt; in hdaa_channel_init()
1777 if (sndbuf_alloc(ch->b, bus_get_dma_tag(devinfo->dev), in hdaa_channel_init()
1778 hda_get_dma_nocache(devinfo->dev) ? BUS_DMA_NOCACHE : in hdaa_channel_init()
1780 pdevinfo->chan_size) != 0) in hdaa_channel_init()
1792 for (i = 0; ch->caps.fmtlist[i] != 0; i++) { in hdaa_channel_setformat()
1793 if (format == ch->caps.fmtlist[i]) { in hdaa_channel_setformat()
1794 ch->fmt = format; in hdaa_channel_setformat()
1810 for (i = 0; ch->pcmrates[i] != 0; i++) { in hdaa_channel_setspeed()
1811 spd = ch->pcmrates[i]; in hdaa_channel_setspeed()
1813 ch->spd = spd; in hdaa_channel_setspeed()
1818 for (i = 0; ch->pcmrates[i] != 0; i++) { in hdaa_channel_setspeed()
1819 spd = ch->pcmrates[i]; in hdaa_channel_setspeed()
1820 threshold = spd + ((ch->pcmrates[i + 1] != 0) ? in hdaa_channel_setspeed()
1821 ((ch->pcmrates[i + 1] - spd) >> 1) : 0); in hdaa_channel_setspeed()
1825 ch->spd = spd; in hdaa_channel_setspeed()
1836 if (ch->fmt & AFMT_S16_LE) in hdaa_stream_format()
1837 fmt |= ch->bit16 << 4; in hdaa_stream_format()
1838 else if (ch->fmt & AFMT_S32_LE) in hdaa_stream_format()
1839 fmt |= ch->bit32 << 4; in hdaa_stream_format()
1843 if (hda_rate_tab[i].valid && ch->spd == hda_rate_tab[i].rate) { in hdaa_stream_format()
1850 fmt |= (AFMT_CHANNEL(ch->fmt) - 1); in hdaa_stream_format()
1864 return (0xffffffffU >> (32 - fls(size / 8))); in hdaa_allowed_stripes()
1870 struct hdaa_audio_as *as = &ch->devinfo->as[ch->as]; in hdaa_audio_setup()
1891 int convmapid = -1; in hdaa_audio_setup()
1895 totalchn = AFMT_CHANNEL(ch->fmt); in hdaa_audio_setup()
1896 totalextchn = AFMT_EXTCHANNEL(ch->fmt); in hdaa_audio_setup()
1898 device_printf(ch->pdevinfo->dev, in hdaa_audio_setup()
1900 (ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC", in hdaa_audio_setup()
1901 ch->fmt, totalchn - totalextchn, totalextchn, ch->spd); in hdaa_audio_setup()
1906 if ((as->pinset == 0x0007 || as->pinset == 0x0013) || /* Standard 5.1 */ in hdaa_audio_setup()
1907 (as->pinset == 0x0017)) /* Standard 7.1 */ in hdaa_audio_setup()
1908 convmapid = (ch->dir == PCMDIR_PLAY); in hdaa_audio_setup()
1911 if (ch->fmt & AFMT_AC3) in hdaa_audio_setup()
1915 for (i = 0; ch->io[i] != -1; i++) { in hdaa_audio_setup()
1916 w = hdaa_widget_get(ch->devinfo, ch->io[i]); in hdaa_audio_setup()
1922 if (as->fakeredir && i == (as->pincnt - 1)) { in hdaa_audio_setup()
1923 c = (ch->sid << 4); in hdaa_audio_setup()
1928 >> i * 4) & 0xf) - 1) * 2; in hdaa_audio_setup()
1932 c = (ch->sid << 4) | chn; in hdaa_audio_setup()
1935 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
1936 HDA_CMD_SET_CONV_FMT(0, ch->io[i], fmt)); in hdaa_audio_setup()
1937 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) { in hdaa_audio_setup()
1938 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
1939 HDA_CMD_SET_DIGITAL_CONV_FMT1(0, ch->io[i], dfmt)); in hdaa_audio_setup()
1941 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
1942 HDA_CMD_SET_CONV_STREAM_CHAN(0, ch->io[i], c)); in hdaa_audio_setup()
1943 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap)) { in hdaa_audio_setup()
1944 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
1945 HDA_CMD_SET_STRIPE_CONTROL(0, w->nid, ch->stripectl)); in hdaa_audio_setup()
1947 cchn = HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap); in hdaa_audio_setup()
1949 cchn = min(cchn, totalchn - chn - 1); in hdaa_audio_setup()
1950 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
1951 HDA_CMD_SET_CONV_CHAN_COUNT(0, ch->io[i], cchn)); in hdaa_audio_setup()
1954 device_printf(ch->pdevinfo->dev, in hdaa_audio_setup()
1958 (ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC", in hdaa_audio_setup()
1959 ch->io[i], fmt, dfmt, c, cchn, ch->stripectl); in hdaa_audio_setup()
1962 if (as->dacs[ch->asindex][j] != ch->io[i]) in hdaa_audio_setup()
1964 nid = as->pins[j]; in hdaa_audio_setup()
1965 wp = hdaa_widget_get(ch->devinfo, nid); in hdaa_audio_setup()
1968 if (!HDA_PARAM_PIN_CAP_DP(wp->wclass.pin.cap) && in hdaa_audio_setup()
1969 !HDA_PARAM_PIN_CAP_HDMI(wp->wclass.pin.cap)) in hdaa_audio_setup()
1974 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
1976 (((hdmich[totalextchn == 0 ? 0 : 1][totalchn - 1] in hdaa_audio_setup()
1984 if (HDA_PARAM_PIN_CAP_HDMI(wp->wclass.pin.cap) && in hdaa_audio_setup()
1985 HDA_PARAM_PIN_CAP_HBR(wp->wclass.pin.cap)) { in hdaa_audio_setup()
1986 wp->wclass.pin.ctrl &= in hdaa_audio_setup()
1988 if ((ch->fmt & AFMT_AC3) && (cchn == 7)) in hdaa_audio_setup()
1989 wp->wclass.pin.ctrl |= 0x03; in hdaa_audio_setup()
1990 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
1992 wp->wclass.pin.ctrl)); in hdaa_audio_setup()
1996 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
1998 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2002 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2005 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2009 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2011 if (w->eld != NULL && w->eld_len >= 6 && in hdaa_audio_setup()
2012 ((w->eld[5] >> 2) & 0x3) == 1) { /* DisplayPort */ in hdaa_audio_setup()
2013 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2015 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2017 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2020 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2022 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2024 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2027 csum -= 0x84 + 0x01 + 0x0a + (totalchn - 1) + in hdaa_audio_setup()
2028 hdmica[totalextchn == 0 ? 0 : 1][totalchn - 1]; in hdaa_audio_setup()
2029 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2032 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2033 HDA_CMD_SET_HDMI_DIP_DATA(0, nid, totalchn - 1)); in hdaa_audio_setup()
2034 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2036 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2038 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2040 hdmica[totalextchn == 0 ? 0 : 1][totalchn - 1])); in hdaa_audio_setup()
2043 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2045 hda_command(ch->devinfo->dev, in hdaa_audio_setup()
2084 blksz -= blksz % lcm(HDA_DMA_ALIGNMENT, sndbuf_getalign(ch->b)); in hdaa_channel_setfragments()
2086 if (blksz > (sndbuf_getmaxsize(ch->b) / HDA_BDL_MIN)) in hdaa_channel_setfragments()
2087 blksz = sndbuf_getmaxsize(ch->b) / HDA_BDL_MIN; in hdaa_channel_setfragments()
2095 while ((blksz * blkcnt) > sndbuf_getmaxsize(ch->b)) { in hdaa_channel_setfragments()
2104 if ((sndbuf_getblksz(ch->b) != blksz || in hdaa_channel_setfragments()
2105 sndbuf_getblkcnt(ch->b) != blkcnt) && in hdaa_channel_setfragments()
2106 sndbuf_resize(ch->b, blkcnt, blksz) != 0) in hdaa_channel_setfragments()
2107 device_printf(ch->devinfo->dev, "%s: failed blksz=%u blkcnt=%u\n", in hdaa_channel_setfragments()
2110 ch->blksz = sndbuf_getblksz(ch->b); in hdaa_channel_setfragments()
2111 ch->blkcnt = sndbuf_getblkcnt(ch->b); in hdaa_channel_setfragments()
2121 hdaa_channel_setfragments(obj, data, blksz, ch->pdevinfo->chan_blkcnt); in hdaa_channel_setblocksize()
2123 return (ch->blksz); in hdaa_channel_setblocksize()
2129 struct hdaa_devinfo *devinfo = ch->devinfo; in hdaa_channel_stop()
2133 if ((ch->flags & HDAA_CHN_RUNNING) == 0) in hdaa_channel_stop()
2135 ch->flags &= ~HDAA_CHN_RUNNING; in hdaa_channel_stop()
2136 HDAC_STREAM_STOP(device_get_parent(devinfo->dev), devinfo->dev, in hdaa_channel_stop()
2137 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid); in hdaa_channel_stop()
2138 for (i = 0; ch->io[i] != -1; i++) { in hdaa_channel_stop()
2139 w = hdaa_widget_get(ch->devinfo, ch->io[i]); in hdaa_channel_stop()
2142 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) { in hdaa_channel_stop()
2143 hda_command(devinfo->dev, in hdaa_channel_stop()
2144 HDA_CMD_SET_DIGITAL_CONV_FMT1(0, ch->io[i], 0)); in hdaa_channel_stop()
2146 hda_command(devinfo->dev, in hdaa_channel_stop()
2147 HDA_CMD_SET_CONV_STREAM_CHAN(0, ch->io[i], in hdaa_channel_stop()
2150 HDAC_STREAM_FREE(device_get_parent(devinfo->dev), devinfo->dev, in hdaa_channel_stop()
2151 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid); in hdaa_channel_stop()
2157 struct hdaa_devinfo *devinfo = ch->devinfo; in hdaa_channel_start()
2161 ch->stripectl = fls(ch->stripecap & hdaa_allowed_stripes(fmt) & in hdaa_channel_start()
2162 hda_get_stripes_mask(devinfo->dev)) - 1; in hdaa_channel_start()
2163 ch->sid = HDAC_STREAM_ALLOC(device_get_parent(devinfo->dev), devinfo->dev, in hdaa_channel_start()
2164 ch->dir == PCMDIR_PLAY ? 1 : 0, fmt, ch->stripectl, &ch->dmapos); in hdaa_channel_start()
2165 if (ch->sid <= 0) in hdaa_channel_start()
2168 HDAC_STREAM_RESET(device_get_parent(devinfo->dev), devinfo->dev, in hdaa_channel_start()
2169 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid); in hdaa_channel_start()
2170 HDAC_STREAM_START(device_get_parent(devinfo->dev), devinfo->dev, in hdaa_channel_start()
2171 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid, in hdaa_channel_start()
2172 sndbuf_getbufaddr(ch->b), ch->blksz, ch->blkcnt); in hdaa_channel_start()
2173 ch->flags |= HDAA_CHN_RUNNING; in hdaa_channel_start()
2186 hdaa_lock(ch->devinfo); in hdaa_channel_trigger()
2198 hdaa_unlock(ch->devinfo); in hdaa_channel_trigger()
2207 struct hdaa_devinfo *devinfo = ch->devinfo; in hdaa_channel_getptr()
2211 if (ch->dmapos != NULL) { in hdaa_channel_getptr()
2212 ptr = *(ch->dmapos); in hdaa_channel_getptr()
2215 device_get_parent(devinfo->dev), devinfo->dev, in hdaa_channel_getptr()
2216 ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid); in hdaa_channel_getptr()
2223 ptr %= ch->blksz * ch->blkcnt; in hdaa_channel_getptr()
2232 return (&((struct hdaa_chan *)data)->caps); in hdaa_channel_getcaps()
2252 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_audio_ctl_ossmixer_init()
2258 pdevinfo->mixer = m; in hdaa_audio_ctl_ossmixer_init()
2262 pdevinfo->left[i] = 100; in hdaa_audio_ctl_ossmixer_init()
2263 pdevinfo->right[i] = 100; in hdaa_audio_ctl_ossmixer_init()
2267 mask = pdevinfo->ossmask; in hdaa_audio_ctl_ossmixer_init()
2268 if (pdevinfo->playas >= 0) { in hdaa_audio_ctl_ossmixer_init()
2270 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_ctl_ossmixer_init()
2272 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_ossmixer_init()
2274 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || in hdaa_audio_ctl_ossmixer_init()
2275 w->param.eapdbtl == HDA_INVALID || in hdaa_audio_ctl_ossmixer_init()
2276 w->bindas != pdevinfo->playas) in hdaa_audio_ctl_ossmixer_init()
2284 (devinfo->quirks & HDAA_QUIRK_SOFTPCMVOL) || in hdaa_audio_ctl_ossmixer_init()
2285 pdevinfo->minamp[SOUND_MIXER_PCM] == in hdaa_audio_ctl_ossmixer_init()
2286 pdevinfo->maxamp[SOUND_MIXER_PCM]) { in hdaa_audio_ctl_ossmixer_init()
2288 pcm_setflags(pdevinfo->dev, pcm_getflags(pdevinfo->dev) | SD_F_SOFTPCMVOL); in hdaa_audio_ctl_ossmixer_init()
2290 device_printf(pdevinfo->dev, in hdaa_audio_ctl_ossmixer_init()
2303 device_printf(pdevinfo->dev, in hdaa_audio_ctl_ossmixer_init()
2311 if (pdevinfo->recas >= 0) { in hdaa_audio_ctl_ossmixer_init()
2313 if (devinfo->as[pdevinfo->recas].dacs[0][i] < 0) in hdaa_audio_ctl_ossmixer_init()
2316 devinfo->as[pdevinfo->recas].dacs[0][i]); in hdaa_audio_ctl_ossmixer_init()
2317 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_ossmixer_init()
2319 for (j = 0; j < w->nconns; j++) { in hdaa_audio_ctl_ossmixer_init()
2320 if (w->connsenable[j] == 0) in hdaa_audio_ctl_ossmixer_init()
2322 cw = hdaa_widget_get(devinfo, w->conns[j]); in hdaa_audio_ctl_ossmixer_init()
2323 if (cw == NULL || cw->enable == 0) in hdaa_audio_ctl_ossmixer_init()
2325 if (cw->bindas != pdevinfo->recas && in hdaa_audio_ctl_ossmixer_init()
2326 cw->bindas != -2) in hdaa_audio_ctl_ossmixer_init()
2328 recmask |= cw->ossmask; in hdaa_audio_ctl_ossmixer_init()
2333 recmask &= (1 << SOUND_MIXER_NRDEVICES) - 1; in hdaa_audio_ctl_ossmixer_init()
2334 mask &= (1 << SOUND_MIXER_NRDEVICES) - 1; in hdaa_audio_ctl_ossmixer_init()
2335 pdevinfo->ossmask = mask; in hdaa_audio_ctl_ossmixer_init()
2355 ctl->devleft[ossdev] = *left; in hdaa_audio_ctl_dev_set()
2356 ctl->devright[ossdev] = *right; in hdaa_audio_ctl_dev_set()
2357 ctl->devmute[ossdev] = mute; in hdaa_audio_ctl_dev_set()
2360 sleft += ctl->devleft[i]; in hdaa_audio_ctl_dev_set()
2361 sright += ctl->devright[i]; in hdaa_audio_ctl_dev_set()
2362 smute |= ctl->devmute[i]; in hdaa_audio_ctl_dev_set()
2365 zleft += ctl->devleft[i]; in hdaa_audio_ctl_dev_set()
2366 zright += ctl->devright[i]; in hdaa_audio_ctl_dev_set()
2371 *left -= VAL2QDB(ctl, lval) - VAL2QDB(ctl, QDB2VAL(ctl, zleft)); in hdaa_audio_ctl_dev_set()
2372 *right -= VAL2QDB(ctl, rval) - VAL2QDB(ctl, QDB2VAL(ctl, zright)); in hdaa_audio_ctl_dev_set()
2382 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_audio_ctl_source_volume()
2391 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_source_volume()
2396 for (j = 0; j < w->nconns; j++) { in hdaa_audio_ctl_source_volume()
2397 if (!w->connsenable[j]) in hdaa_audio_ctl_source_volume()
2403 /* If this is not a first step - use input mixer. in hdaa_audio_ctl_source_volume()
2406 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)) { in hdaa_audio_ctl_source_volume()
2407 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, HDAA_CTL_IN, in hdaa_audio_ctl_source_volume()
2413 /* If widget has own ossdev - not traverse it. in hdaa_audio_ctl_source_volume()
2415 if (w->ossdev >= 0 && depth > 0) in hdaa_audio_ctl_source_volume()
2419 if ((w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT || in hdaa_audio_ctl_source_volume()
2420 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) && in hdaa_audio_ctl_source_volume()
2429 (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER || in hdaa_audio_ctl_source_volume()
2430 w->selconn != index)) in hdaa_audio_ctl_source_volume()
2433 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, HDAA_CTL_OUT, -1, 1); in hdaa_audio_ctl_source_volume()
2437 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_ctl_source_volume()
2439 if (wc == NULL || wc->enable == 0) in hdaa_audio_ctl_source_volume()
2441 for (j = 0; j < wc->nconns; j++) { in hdaa_audio_ctl_source_volume()
2442 if (wc->connsenable[j] && wc->conns[j] == nid) { in hdaa_audio_ctl_source_volume()
2444 wc->nid, j, mute, left, right, depth + 1); in hdaa_audio_ctl_source_volume()
2458 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_audio_ctl_dest_volume()
2459 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_ctl_dest_volume()
2468 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_dest_volume()
2475 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_ctl_dest_volume()
2477 if (wc == NULL || wc->enable == 0) in hdaa_audio_ctl_dest_volume()
2479 for (j = 0; j < wc->nconns; j++) { in hdaa_audio_ctl_dest_volume()
2480 if (wc->connsenable[j] && wc->conns[j] == nid) in hdaa_audio_ctl_dest_volume()
2488 if ((consumers == 2 && (w->bindas < 0 || in hdaa_audio_ctl_dest_volume()
2489 as[w->bindas].hpredir < 0 || as[w->bindas].fakeredir || in hdaa_audio_ctl_dest_volume()
2490 (w->bindseqmask & (1 << 15)) == 0)) || in hdaa_audio_ctl_dest_volume()
2495 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, in hdaa_audio_ctl_dest_volume()
2496 HDAA_CTL_OUT, -1, 1); in hdaa_audio_ctl_dest_volume()
2502 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX && in hdaa_audio_ctl_dest_volume()
2506 for (i = 0; i < w->nconns; i++) { in hdaa_audio_ctl_dest_volume()
2507 if (w->connsenable[i] == 0) in hdaa_audio_ctl_dest_volume()
2513 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, in hdaa_audio_ctl_dest_volume()
2517 hdaa_audio_ctl_dest_volume(pdevinfo, ossdev, w->conns[i], -1, in hdaa_audio_ctl_dest_volume()
2528 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_audio_ctl_dev_volume()
2535 if (pdevinfo->left[dev] == 0) { in hdaa_audio_ctl_dev_volume()
2537 lvol = -4000; in hdaa_audio_ctl_dev_volume()
2539 lvol = ((pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]) * in hdaa_audio_ctl_dev_volume()
2540 pdevinfo->left[dev] + 50) / 100 + pdevinfo->minamp[dev]; in hdaa_audio_ctl_dev_volume()
2541 if (pdevinfo->right[dev] == 0) { in hdaa_audio_ctl_dev_volume()
2543 rvol = -4000; in hdaa_audio_ctl_dev_volume()
2545 rvol = ((pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]) * in hdaa_audio_ctl_dev_volume()
2546 pdevinfo->right[dev] + 50) / 100 + pdevinfo->minamp[dev]; in hdaa_audio_ctl_dev_volume()
2547 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_ctl_dev_volume()
2549 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_dev_volume()
2551 if (w->bindas < 0) { in hdaa_audio_ctl_dev_volume()
2552 if (pdevinfo->index != 0) in hdaa_audio_ctl_dev_volume()
2555 if (w->bindas != pdevinfo->playas && in hdaa_audio_ctl_dev_volume()
2556 w->bindas != pdevinfo->recas) in hdaa_audio_ctl_dev_volume()
2560 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) { in hdaa_audio_ctl_dev_volume()
2562 w->nid, -1, mute, lvol, rvol, 0); in hdaa_audio_ctl_dev_volume()
2566 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX && in hdaa_audio_ctl_dev_volume()
2567 devinfo->as[w->bindas].dir == HDAA_CTL_OUT) { in hdaa_audio_ctl_dev_volume()
2569 w->nid, -1, mute, lvol, rvol, 0); in hdaa_audio_ctl_dev_volume()
2573 w->pflags & HDAA_ADC_MONITOR) { in hdaa_audio_ctl_dev_volume()
2574 for (j = 0; j < w->nconns; j++) { in hdaa_audio_ctl_dev_volume()
2575 if (!w->connsenable[j]) in hdaa_audio_ctl_dev_volume()
2577 cw = hdaa_widget_get(devinfo, w->conns[j]); in hdaa_audio_ctl_dev_volume()
2578 if (cw == NULL || cw->enable == 0) in hdaa_audio_ctl_dev_volume()
2580 if (cw->bindas == -1) in hdaa_audio_ctl_dev_volume()
2582 if (cw->bindas >= 0 && in hdaa_audio_ctl_dev_volume()
2583 devinfo->as[cw->bindas].dir != HDAA_CTL_IN) in hdaa_audio_ctl_dev_volume()
2586 w->nid, j, mute, lvol, rvol, 0); in hdaa_audio_ctl_dev_volume()
2590 if (w->ossdev != dev) in hdaa_audio_ctl_dev_volume()
2593 w->nid, -1, mute, lvol, rvol, 0); in hdaa_audio_ctl_dev_volume()
2594 if (dev == SOUND_MIXER_IMIX && (w->pflags & HDAA_IMIX_AS_DST)) in hdaa_audio_ctl_dev_volume()
2596 w->nid, -1, mute, lvol, rvol, 0); in hdaa_audio_ctl_dev_volume()
2608 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_audio_ctl_ossmixer_set()
2615 pdevinfo->left[dev] = left; in hdaa_audio_ctl_ossmixer_set()
2616 pdevinfo->right[dev] = right; in hdaa_audio_ctl_ossmixer_set()
2622 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_ctl_ossmixer_set()
2624 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_ossmixer_set()
2626 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || in hdaa_audio_ctl_ossmixer_set()
2627 w->param.eapdbtl == HDA_INVALID) in hdaa_audio_ctl_ossmixer_set()
2631 if (i >= devinfo->endnode) { in hdaa_audio_ctl_ossmixer_set()
2633 return (-1); in hdaa_audio_ctl_ossmixer_set()
2635 orig = w->param.eapdbtl; in hdaa_audio_ctl_ossmixer_set()
2637 w->param.eapdbtl &= ~HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD; in hdaa_audio_ctl_ossmixer_set()
2639 w->param.eapdbtl |= HDA_CMD_SET_EAPD_BTL_ENABLE_EAPD; in hdaa_audio_ctl_ossmixer_set()
2640 if (orig != w->param.eapdbtl) { in hdaa_audio_ctl_ossmixer_set()
2643 val = w->param.eapdbtl; in hdaa_audio_ctl_ossmixer_set()
2644 if (devinfo->quirks & HDAA_QUIRK_EAPDINV) in hdaa_audio_ctl_ossmixer_set()
2646 hda_command(devinfo->dev, in hdaa_audio_ctl_ossmixer_set()
2647 HDA_CMD_SET_EAPD_BTL_ENABLE(0, w->nid, val)); in hdaa_audio_ctl_ossmixer_set()
2662 * +20dB for mics, -10dB for analog vol, mute for igain, 0dB for others.
2670 if ((pdevinfo->ossmask & (1 << dev)) == 0) in hdaa_audio_ctl_set_defaults()
2674 if (resource_int_value(device_get_name(pdevinfo->dev), in hdaa_audio_ctl_set_defaults()
2675 device_get_unit(pdevinfo->dev), ossnames[dev], &vol) == 0) in hdaa_audio_ctl_set_defaults()
2678 vol = -1; in hdaa_audio_ctl_set_defaults()
2686 else if (dev == SOUND_MIXER_VOLUME && !pdevinfo->digital) in hdaa_audio_ctl_set_defaults()
2687 amp = -10 * 4; /* -10dB */ in hdaa_audio_ctl_set_defaults()
2691 (pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]) <= 0) { in hdaa_audio_ctl_set_defaults()
2694 vol = ((amp - pdevinfo->minamp[dev]) * 100 + in hdaa_audio_ctl_set_defaults()
2695 (pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]) / 2) / in hdaa_audio_ctl_set_defaults()
2696 (pdevinfo->maxamp[dev] - pdevinfo->minamp[dev]); in hdaa_audio_ctl_set_defaults()
2699 mix_set(pdevinfo->mixer, dev, vol, vol); in hdaa_audio_ctl_set_defaults()
2709 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_audio_ctl_recsel_comm()
2720 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_recsel_comm()
2723 for (i = 0; i < w->nconns; i++) { in hdaa_audio_ctl_recsel_comm()
2724 if (w->connsenable[i] == 0) in hdaa_audio_ctl_recsel_comm()
2726 cw = hdaa_widget_get(devinfo, w->conns[i]); in hdaa_audio_ctl_recsel_comm()
2727 if (cw == NULL || cw->enable == 0 || cw->bindas == -1) in hdaa_audio_ctl_recsel_comm()
2730 if ((src & cw->ossmask) != 0) { in hdaa_audio_ctl_recsel_comm()
2731 if (cw->ossdev < 0) { in hdaa_audio_ctl_recsel_comm()
2733 w->conns[i], depth + 1); in hdaa_audio_ctl_recsel_comm()
2735 res |= cw->ossmask; in hdaa_audio_ctl_recsel_comm()
2739 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) { in hdaa_audio_ctl_recsel_comm()
2741 w->nid, HDAA_CTL_IN, i, 1); in hdaa_audio_ctl_recsel_comm()
2746 muted = (src & cw->ossmask) ? 0 : 1; in hdaa_audio_ctl_recsel_comm()
2747 if (muted != ctl->forcemute) { in hdaa_audio_ctl_recsel_comm()
2748 ctl->forcemute = muted; in hdaa_audio_ctl_recsel_comm()
2754 device_printf(pdevinfo->dev, in hdaa_audio_ctl_recsel_comm()
2761 if (w->nconns == 1) in hdaa_audio_ctl_recsel_comm()
2763 if ((src & cw->ossmask) == 0) in hdaa_audio_ctl_recsel_comm()
2765 /* If we found requested source - select it and exit. */ in hdaa_audio_ctl_recsel_comm()
2768 device_printf(pdevinfo->dev, in hdaa_audio_ctl_recsel_comm()
2784 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_audio_ctl_ossmixer_setrecsrc()
2793 if (pdevinfo->recas < 0) { in hdaa_audio_ctl_ossmixer_setrecsrc()
2797 as = &devinfo->as[pdevinfo->recas]; in hdaa_audio_ctl_ossmixer_setrecsrc()
2799 /* For non-mixed associations we always recording everything. */ in hdaa_audio_ctl_ossmixer_setrecsrc()
2800 if (!as->mixed) { in hdaa_audio_ctl_ossmixer_setrecsrc()
2806 for (j = 0; j < as->num_chans; j++) { in hdaa_audio_ctl_ossmixer_setrecsrc()
2807 ch = &devinfo->chans[as->chans[j]]; in hdaa_audio_ctl_ossmixer_setrecsrc()
2808 for (i = 0; ch->io[i] >= 0; i++) { in hdaa_audio_ctl_ossmixer_setrecsrc()
2809 w = hdaa_widget_get(devinfo, ch->io[i]); in hdaa_audio_ctl_ossmixer_setrecsrc()
2810 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_ossmixer_setrecsrc()
2813 ch->io[i], 0); in hdaa_audio_ctl_ossmixer_setrecsrc()
2826 if (ctl->enable == 0 || in hdaa_audio_ctl_ossmixer_setrecsrc()
2827 !(ctl->ossmask & pdevinfo->recsrc)) in hdaa_audio_ctl_ossmixer_setrecsrc()
2829 if (!((pdevinfo->playas >= 0 && in hdaa_audio_ctl_ossmixer_setrecsrc()
2830 ctl->widget->bindas == pdevinfo->playas) || in hdaa_audio_ctl_ossmixer_setrecsrc()
2831 (pdevinfo->recas >= 0 && in hdaa_audio_ctl_ossmixer_setrecsrc()
2832 ctl->widget->bindas == pdevinfo->recas) || in hdaa_audio_ctl_ossmixer_setrecsrc()
2833 (pdevinfo->index == 0 && in hdaa_audio_ctl_ossmixer_setrecsrc()
2834 ctl->widget->bindas == -2))) in hdaa_audio_ctl_ossmixer_setrecsrc()
2837 if (pdevinfo->recsrc & (1 << j)) { in hdaa_audio_ctl_ossmixer_setrecsrc()
2838 ctl->devleft[j] = 0; in hdaa_audio_ctl_ossmixer_setrecsrc()
2839 ctl->devright[j] = 0; in hdaa_audio_ctl_ossmixer_setrecsrc()
2840 ctl->devmute[j] = 0; in hdaa_audio_ctl_ossmixer_setrecsrc()
2850 if ((ret | pdevinfo->recsrc) & (1 << j)) in hdaa_audio_ctl_ossmixer_setrecsrc()
2854 pdevinfo->recsrc = ret; in hdaa_audio_ctl_ossmixer_setrecsrc()
2870 device_t dev = devinfo->dev; in hdaa_dump_gpi()
2874 if (HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap) > 0) { in hdaa_dump_gpi()
2876 HDA_CMD_GET_GPI_DATA(0, devinfo->nid)); in hdaa_dump_gpi()
2878 HDA_CMD_GET_GPI_WAKE_ENABLE_MASK(0, devinfo->nid)); in hdaa_dump_gpi()
2880 HDA_CMD_GET_GPI_UNSOLICITED_ENABLE_MASK(0, devinfo->nid)); in hdaa_dump_gpi()
2882 HDA_CMD_GET_GPI_STICKY_MASK(0, devinfo->nid)); in hdaa_dump_gpi()
2883 for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap); i++) { in hdaa_dump_gpi()
2896 device_t dev = devinfo->dev; in hdaa_dump_gpio()
2900 if (HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap) > 0) { in hdaa_dump_gpio()
2902 HDA_CMD_GET_GPIO_DATA(0, devinfo->nid)); in hdaa_dump_gpio()
2904 HDA_CMD_GET_GPIO_ENABLE_MASK(0, devinfo->nid)); in hdaa_dump_gpio()
2906 HDA_CMD_GET_GPIO_DIRECTION(0, devinfo->nid)); in hdaa_dump_gpio()
2908 HDA_CMD_GET_GPIO_WAKE_ENABLE_MASK(0, devinfo->nid)); in hdaa_dump_gpio()
2910 HDA_CMD_GET_GPIO_UNSOLICITED_ENABLE_MASK(0, devinfo->nid)); in hdaa_dump_gpio()
2912 HDA_CMD_GET_GPIO_STICKY_MASK(0, devinfo->nid)); in hdaa_dump_gpio()
2913 for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap); i++) { in hdaa_dump_gpio()
2934 device_t dev = devinfo->dev; in hdaa_dump_gpo()
2938 if (HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap) > 0) { in hdaa_dump_gpo()
2940 HDA_CMD_GET_GPO_DATA(0, devinfo->nid)); in hdaa_dump_gpo()
2941 for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap); i++) { in hdaa_dump_gpo()
2956 nid = devinfo->nid; in hdaa_audio_parse()
2958 res = hda_command(devinfo->dev, in hdaa_audio_parse()
2960 devinfo->gpio_cap = res; in hdaa_audio_parse()
2963 device_printf(devinfo->dev, in hdaa_audio_parse()
2966 HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap), in hdaa_audio_parse()
2967 HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap), in hdaa_audio_parse()
2968 HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap), in hdaa_audio_parse()
2969 HDA_PARAM_GPIO_COUNT_GPI_WAKE(devinfo->gpio_cap), in hdaa_audio_parse()
2970 HDA_PARAM_GPIO_COUNT_GPI_UNSOL(devinfo->gpio_cap)); in hdaa_audio_parse()
2976 res = hda_command(devinfo->dev, in hdaa_audio_parse()
2978 devinfo->supp_stream_formats = res; in hdaa_audio_parse()
2980 res = hda_command(devinfo->dev, in hdaa_audio_parse()
2982 devinfo->supp_pcm_size_rate = res; in hdaa_audio_parse()
2984 res = hda_command(devinfo->dev, in hdaa_audio_parse()
2986 devinfo->outamp_cap = res; in hdaa_audio_parse()
2988 res = hda_command(devinfo->dev, in hdaa_audio_parse()
2990 devinfo->inamp_cap = res; in hdaa_audio_parse()
2992 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_parse()
2995 device_printf(devinfo->dev, "Ghost widget! nid=%d!\n", i); in hdaa_audio_parse()
2997 w->devinfo = devinfo; in hdaa_audio_parse()
2998 w->nid = i; in hdaa_audio_parse()
2999 w->enable = 1; in hdaa_audio_parse()
3000 w->selconn = -1; in hdaa_audio_parse()
3001 w->pflags = 0; in hdaa_audio_parse()
3002 w->ossdev = -1; in hdaa_audio_parse()
3003 w->bindas = -1; in hdaa_audio_parse()
3004 w->param.eapdbtl = HDA_INVALID; in hdaa_audio_parse()
3016 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_postprocess()
3034 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_ctl_parse()
3036 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_parse()
3038 if (w->param.outamp_cap != 0) in hdaa_audio_ctl_parse()
3040 if (w->param.inamp_cap != 0) { in hdaa_audio_ctl_parse()
3041 switch (w->type) { in hdaa_audio_ctl_parse()
3044 for (j = 0; j < w->nconns; j++) { in hdaa_audio_ctl_parse()
3046 w->conns[j]); in hdaa_audio_ctl_parse()
3047 if (cw == NULL || cw->enable == 0) in hdaa_audio_ctl_parse()
3058 devinfo->ctlcnt = max; in hdaa_audio_ctl_parse()
3067 device_printf(devinfo->dev, "unable to allocate ctls!\n"); in hdaa_audio_ctl_parse()
3068 devinfo->ctlcnt = 0; in hdaa_audio_ctl_parse()
3073 for (i = devinfo->startnode; cnt < max && i < devinfo->endnode; i++) { in hdaa_audio_ctl_parse()
3075 device_printf(devinfo->dev, "%s: Ctl overflow!\n", in hdaa_audio_ctl_parse()
3080 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_parse()
3082 ocap = w->param.outamp_cap; in hdaa_audio_ctl_parse()
3083 icap = w->param.inamp_cap; in hdaa_audio_ctl_parse()
3091 device_printf(devinfo->dev, in hdaa_audio_ctl_parse()
3094 w->nid, offset, step); in hdaa_audio_ctl_parse()
3106 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || in hdaa_audio_ctl_parse()
3107 w->waspin) in hdaa_audio_ctl_parse()
3121 device_printf(devinfo->dev, in hdaa_audio_ctl_parse()
3124 w->nid, offset, step); in hdaa_audio_ctl_parse()
3128 switch (w->type) { in hdaa_audio_ctl_parse()
3131 for (j = 0; j < w->nconns; j++) { in hdaa_audio_ctl_parse()
3133 device_printf(devinfo->dev, in hdaa_audio_ctl_parse()
3139 w->conns[j]); in hdaa_audio_ctl_parse()
3140 if (cw == NULL || cw->enable == 0) in hdaa_audio_ctl_parse()
3158 device_printf(devinfo->dev, in hdaa_audio_ctl_parse()
3171 if (w->type == in hdaa_audio_ctl_parse()
3182 devinfo->ctl = ctls; in hdaa_audio_ctl_parse()
3195 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_as_parse()
3197 if (w == NULL || w->enable == 0) in hdaa_audio_as_parse()
3199 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_audio_as_parse()
3201 if (HDA_CONFIG_DEFAULTCONF_ASSOCIATION(w->wclass.pin.config) in hdaa_audio_as_parse()
3205 if (j != 15) /* There could be many 1-pin assocs #15 */ in hdaa_audio_as_parse()
3210 devinfo->ascnt = max; in hdaa_audio_as_parse()
3219 device_printf(devinfo->dev, "unable to allocate assocs!\n"); in hdaa_audio_as_parse()
3220 devinfo->ascnt = 0; in hdaa_audio_as_parse()
3225 as[i].hpredir = -1; in hdaa_audio_as_parse()
3228 as[i].location = -1; in hdaa_audio_as_parse()
3236 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_as_parse()
3238 if (w == NULL || w->enable == 0) in hdaa_audio_as_parse()
3240 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_audio_as_parse()
3242 assoc = HDA_CONFIG_DEFAULTCONF_ASSOCIATION(w->wclass.pin.config); in hdaa_audio_as_parse()
3243 seq = HDA_CONFIG_DEFAULTCONF_SEQUENCE(w->wclass.pin.config); in hdaa_audio_as_parse()
3250 type = w->wclass.pin.config & in hdaa_audio_as_parse()
3261 /* If this is a first pin - create new association. */ in hdaa_audio_as_parse()
3271 device_printf(devinfo->dev, "%s: Duplicate pin %d (%d) " in hdaa_audio_as_parse()
3273 __func__, seq, w->nid, j); in hdaa_audio_as_parse()
3277 device_printf(devinfo->dev, "%s: Pin %d has wrong " in hdaa_audio_as_parse()
3280 __func__, w->nid, j); in hdaa_audio_as_parse()
3283 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) { in hdaa_audio_as_parse()
3285 if (HDA_PARAM_PIN_CAP_HDMI(w->wclass.pin.cap)) in hdaa_audio_as_parse()
3287 if (HDA_PARAM_PIN_CAP_DP(w->wclass.pin.cap)) in hdaa_audio_as_parse()
3290 if (as[cnt].location == -1) { in hdaa_audio_as_parse()
3292 HDA_CONFIG_DEFAULTCONF_LOCATION(w->wclass.pin.config); in hdaa_audio_as_parse()
3294 HDA_CONFIG_DEFAULTCONF_LOCATION(w->wclass.pin.config)) { in hdaa_audio_as_parse()
3295 as[cnt].location = -2; in hdaa_audio_as_parse()
3301 as[cnt].pins[seq] = w->nid; in hdaa_audio_as_parse()
3319 device_printf(devinfo->dev, in hdaa_audio_as_parse()
3322 device_printf(devinfo->dev, in hdaa_audio_as_parse()
3329 device_printf(devinfo->dev, in hdaa_audio_as_parse()
3336 devinfo->as = as; in hdaa_audio_as_parse()
3347 int i, im = -1; in hdaa_audio_trace_dac()
3353 if (w == NULL || w->enable == 0) in hdaa_audio_trace_dac()
3357 device_printf(devinfo->dev, in hdaa_audio_trace_dac()
3359 depth + 1, "", w->nid); in hdaa_audio_trace_dac()
3363 if (w->bindas >= 0 && w->bindas != as) { in hdaa_audio_trace_dac()
3366 device_printf(devinfo->dev, in hdaa_audio_trace_dac()
3368 depth + 1, "", w->nid, w->bindas); in hdaa_audio_trace_dac()
3374 if (w->bindseqmask != 0) { in hdaa_audio_trace_dac()
3377 device_printf(devinfo->dev, in hdaa_audio_trace_dac()
3379 depth + 1, "", w->nid, w->bindseqmask); in hdaa_audio_trace_dac()
3385 /* If this is headphones - allow duplicate first pin. */ in hdaa_audio_trace_dac()
3386 if (w->bindseqmask != 0 && in hdaa_audio_trace_dac()
3387 (w->bindseqmask & (1 << dupseq)) == 0) { in hdaa_audio_trace_dac()
3389 device_printf(devinfo->dev, in hdaa_audio_trace_dac()
3391 depth + 1, "", w->nid, w->bindseqmask); in hdaa_audio_trace_dac()
3397 switch (w->type) { in hdaa_audio_trace_dac()
3404 if ((only == 0 || only == w->nid) && in hdaa_audio_trace_dac()
3405 (w->nid >= min) && (dupseq < 0 || w->nid == in hdaa_audio_trace_dac()
3406 devinfo->as[as].dacs[0][dupseq])) in hdaa_audio_trace_dac()
3407 m = w->nid; in hdaa_audio_trace_dac()
3415 for (i = 0; i < w->nconns; i++) { in hdaa_audio_trace_dac()
3416 if (w->connsenable[i] == 0) in hdaa_audio_trace_dac()
3418 if (w->selconn != -1 && w->selconn != i) in hdaa_audio_trace_dac()
3421 w->conns[i], dupseq, min, only, depth + 1)) != 0) { in hdaa_audio_trace_dac()
3430 if (im >= 0 && only && ((w->nconns > 1 && in hdaa_audio_trace_dac()
3431 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) || in hdaa_audio_trace_dac()
3432 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR)) in hdaa_audio_trace_dac()
3433 w->selconn = im; in hdaa_audio_trace_dac()
3437 w->bindas = as; in hdaa_audio_trace_dac()
3438 w->bindseqmask |= (1 << seq); in hdaa_audio_trace_dac()
3442 device_printf(devinfo->dev, in hdaa_audio_trace_dac()
3444 depth + 1, "", w->nid, m); in hdaa_audio_trace_dac()
3464 if (w == NULL || w->enable == 0) in hdaa_audio_trace_adc()
3467 device_printf(devinfo->dev, in hdaa_audio_trace_adc()
3469 depth + 1, "", w->nid); in hdaa_audio_trace_adc()
3472 if (w->bindas >= 0 && w->bindas != as) { in hdaa_audio_trace_adc()
3474 device_printf(devinfo->dev, in hdaa_audio_trace_adc()
3476 depth + 1, "", w->nid, w->bindas); in hdaa_audio_trace_adc()
3480 if (!mixed && w->bindseqmask != 0) { in hdaa_audio_trace_adc()
3482 device_printf(devinfo->dev, in hdaa_audio_trace_adc()
3484 depth + 1, "", w->nid, w->bindseqmask); in hdaa_audio_trace_adc()
3488 switch (w->type) { in hdaa_audio_trace_adc()
3490 if ((only == 0 || only == w->nid) && (w->nid >= min) && in hdaa_audio_trace_adc()
3492 m = w->nid; in hdaa_audio_trace_adc()
3502 for (j = devinfo->startnode; j < devinfo->endnode; j++) { in hdaa_audio_trace_adc()
3504 if (wc == NULL || wc->enable == 0) in hdaa_audio_trace_adc()
3506 im = -1; in hdaa_audio_trace_adc()
3507 for (i = 0; i < wc->nconns; i++) { in hdaa_audio_trace_adc()
3508 if (wc->connsenable[i] == 0) in hdaa_audio_trace_adc()
3510 if (wc->conns[i] != nid) in hdaa_audio_trace_adc()
3526 if (im >= 0 && only && ((wc->nconns > 1 && in hdaa_audio_trace_adc()
3527 wc->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) || in hdaa_audio_trace_adc()
3528 wc->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR)) in hdaa_audio_trace_adc()
3529 wc->selconn = im; in hdaa_audio_trace_adc()
3534 w->bindas = as; in hdaa_audio_trace_adc()
3535 w->bindseqmask |= (1 << seq); in hdaa_audio_trace_adc()
3538 device_printf(devinfo->dev, in hdaa_audio_trace_adc()
3540 depth + 1, "", w->nid, m); in hdaa_audio_trace_adc()
3554 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_undo_trace()
3556 if (w == NULL || w->enable == 0) in hdaa_audio_undo_trace()
3558 if (w->bindas == as) { in hdaa_audio_undo_trace()
3560 w->bindseqmask &= ~(1 << seq); in hdaa_audio_undo_trace()
3561 if (w->bindseqmask == 0) { in hdaa_audio_undo_trace()
3562 w->bindas = -1; in hdaa_audio_undo_trace()
3563 w->selconn = -1; in hdaa_audio_undo_trace()
3566 w->bindas = -1; in hdaa_audio_undo_trace()
3567 w->bindseqmask = 0; in hdaa_audio_undo_trace()
3568 w->selconn = -1; in hdaa_audio_undo_trace()
3580 struct hdaa_audio_as *ases = devinfo->as; in hdaa_audio_trace_as_out()
3587 /* Check if there is no any left. If so - we succeeded. */ in hdaa_audio_trace_as_out()
3591 hpredir = (i == 15 && ases[as].fakeredir == 0)?ases[as].hpredir:-1; in hdaa_audio_trace_as_out()
3595 device_printf(devinfo->dev, in hdaa_audio_trace_as_out()
3606 /* If we failed - return to previous and redo it. */ in hdaa_audio_trace_as_out()
3608 device_printf(devinfo->dev, in hdaa_audio_trace_as_out()
3619 device_printf(devinfo->dev, in hdaa_audio_trace_as_out()
3648 struct hdaa_devinfo *devinfo = w1->devinfo; in hdaa_audio_dacs_equal()
3652 if (memcmp(&w1->param, &w2->param, sizeof(w1->param))) in hdaa_audio_dacs_equal()
3654 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_dacs_equal()
3656 if (w3 == NULL || w3->enable == 0) in hdaa_audio_dacs_equal()
3658 if (w3->bindas != w1->bindas) in hdaa_audio_dacs_equal()
3660 if (w3->nconns == 0) in hdaa_audio_dacs_equal()
3662 c1 = c2 = -1; in hdaa_audio_dacs_equal()
3663 for (j = 0; j < w3->nconns; j++) { in hdaa_audio_dacs_equal()
3664 if (w3->connsenable[j] == 0) in hdaa_audio_dacs_equal()
3666 if (w3->conns[j] == w1->nid) in hdaa_audio_dacs_equal()
3668 if (w3->conns[j] == w2->nid) in hdaa_audio_dacs_equal()
3675 if (w3->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) in hdaa_audio_dacs_equal()
3687 struct hdaa_devinfo *devinfo = w1->devinfo; in hdaa_audio_adcs_equal()
3691 if (memcmp(&w1->param, &w2->param, sizeof(w1->param))) in hdaa_audio_adcs_equal()
3693 if (w1->nconns != 1 || w2->nconns != 1) in hdaa_audio_adcs_equal()
3695 if (w1->conns[0] == w2->conns[0]) in hdaa_audio_adcs_equal()
3697 w3 = hdaa_widget_get(devinfo, w1->conns[0]); in hdaa_audio_adcs_equal()
3698 if (w3 == NULL || w3->enable == 0) in hdaa_audio_adcs_equal()
3700 w4 = hdaa_widget_get(devinfo, w2->conns[0]); in hdaa_audio_adcs_equal()
3701 if (w4 == NULL || w4->enable == 0) in hdaa_audio_adcs_equal()
3703 if (w3->bindas == w4->bindas && w3->bindseqmask == w4->bindseqmask) in hdaa_audio_adcs_equal()
3705 if (w4->bindas >= 0) in hdaa_audio_adcs_equal()
3707 if (w3->type != w4->type) in hdaa_audio_adcs_equal()
3709 if (memcmp(&w3->param, &w4->param, sizeof(w3->param))) in hdaa_audio_adcs_equal()
3711 if (w3->nconns != w4->nconns) in hdaa_audio_adcs_equal()
3713 for (i = 0; i < w3->nconns; i++) { in hdaa_audio_adcs_equal()
3714 if (w3->conns[i] != w4->conns[i]) in hdaa_audio_adcs_equal()
3726 struct hdaa_audio_as *as = &devinfo->as[asid]; in hdaa_audio_adddac()
3732 device_printf(devinfo->dev, in hdaa_audio_adddac()
3735 (as->dir == HDAA_CTL_OUT) ? "DA" : "AD", in hdaa_audio_adddac()
3736 asid, as->index); in hdaa_audio_adddac()
3740 pos = -1; in hdaa_audio_adddac()
3742 if (as->dacs[0][i] <= 0) in hdaa_audio_adddac()
3744 if (pos >= 0 && as->dacs[0][i] != as->dacs[0][pos]) in hdaa_audio_adddac()
3749 nid1 = as->dacs[0][pos]; in hdaa_audio_adddac()
3752 for (nid2 = devinfo->startnode; nid2 < devinfo->endnode; nid2++) { in hdaa_audio_adddac()
3754 if (w2 == NULL || w2->enable == 0) in hdaa_audio_adddac()
3756 if (w2->bindas >= 0) in hdaa_audio_adddac()
3758 if (w1->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT) { in hdaa_audio_adddac()
3759 if (w2->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT) in hdaa_audio_adddac()
3764 if (w2->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) in hdaa_audio_adddac()
3770 if (nid2 >= devinfo->endnode) in hdaa_audio_adddac()
3772 w2->bindas = w1->bindas; in hdaa_audio_adddac()
3773 w2->bindseqmask = w1->bindseqmask; in hdaa_audio_adddac()
3774 if (w1->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) { in hdaa_audio_adddac()
3776 device_printf(devinfo->dev, in hdaa_audio_adddac()
3779 w1 = hdaa_widget_get(devinfo, w1->conns[0]); in hdaa_audio_adddac()
3780 w2 = hdaa_widget_get(devinfo, w2->conns[0]); in hdaa_audio_adddac()
3781 w2->bindas = w1->bindas; in hdaa_audio_adddac()
3782 w2->bindseqmask = w1->bindseqmask; in hdaa_audio_adddac()
3785 device_printf(devinfo->dev, in hdaa_audio_adddac()
3790 if (as->dacs[0][i] <= 0) in hdaa_audio_adddac()
3792 as->dacs[as->num_chans][i] = nid2; in hdaa_audio_adddac()
3794 as->num_chans++; in hdaa_audio_adddac()
3803 struct hdaa_audio_as *ases = devinfo->as; in hdaa_audio_trace_as_in()
3807 for (j = devinfo->startnode; j < devinfo->endnode; j++) { in hdaa_audio_trace_as_in()
3809 if (w == NULL || w->enable == 0) in hdaa_audio_trace_as_in()
3811 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) in hdaa_audio_trace_as_in()
3813 if (w->bindas >= 0 && w->bindas != as) in hdaa_audio_trace_as_in()
3822 device_printf(devinfo->dev, in hdaa_audio_trace_as_in()
3829 /* If we failed - return to previous and redo it. */ in hdaa_audio_trace_as_in()
3831 device_printf(devinfo->dev, in hdaa_audio_trace_as_in()
3835 hdaa_audio_undo_trace(devinfo, as, -1); in hdaa_audio_trace_as_in()
3841 device_printf(devinfo->dev, in hdaa_audio_trace_as_in()
3859 struct hdaa_audio_as *ases = devinfo->as; in hdaa_audio_trace_as_in_mch()
3866 /* Check if there is no any left. If so - we succeeded. */ in hdaa_audio_trace_as_in_mch()
3873 device_printf(devinfo->dev, in hdaa_audio_trace_as_in_mch()
3882 /* If we failed - return to previous and redo it. */ in hdaa_audio_trace_as_in_mch()
3884 device_printf(devinfo->dev, in hdaa_audio_trace_as_in_mch()
3893 device_printf(devinfo->dev, in hdaa_audio_trace_as_in_mch()
3917 struct hdaa_audio_as *ases = devinfo->as; in hdaa_audio_trace_to_out()
3925 if (w == NULL || w->enable == 0) in hdaa_audio_trace_to_out()
3928 device_printf(devinfo->dev, in hdaa_audio_trace_to_out()
3930 depth + 1, "", w->nid); in hdaa_audio_trace_to_out()
3933 if (depth > 0 && w->bindas != -1) { in hdaa_audio_trace_to_out()
3934 if (w->bindas < 0 || ases[w->bindas].dir == HDAA_CTL_OUT) { in hdaa_audio_trace_to_out()
3936 device_printf(devinfo->dev, in hdaa_audio_trace_to_out()
3938 depth + 1, "", w->nid, w->bindas); in hdaa_audio_trace_to_out()
3940 if (w->bindas >= 0) in hdaa_audio_trace_to_out()
3941 w->pflags |= HDAA_ADC_MONITOR; in hdaa_audio_trace_to_out()
3945 device_printf(devinfo->dev, in hdaa_audio_trace_to_out()
3947 depth + 1, "", w->nid, w->bindas); in hdaa_audio_trace_to_out()
3953 switch (w->type) { in hdaa_audio_trace_to_out()
3964 for (j = devinfo->startnode; j < devinfo->endnode; j++) { in hdaa_audio_trace_to_out()
3966 if (wc == NULL || wc->enable == 0) in hdaa_audio_trace_to_out()
3968 for (i = 0; i < wc->nconns; i++) { in hdaa_audio_trace_to_out()
3969 if (wc->connsenable[i] == 0) in hdaa_audio_trace_to_out()
3971 if (wc->conns[i] != nid) in hdaa_audio_trace_to_out()
3976 if (wc->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR && in hdaa_audio_trace_to_out()
3977 wc->selconn == -1) in hdaa_audio_trace_to_out()
3978 wc->selconn = i; in hdaa_audio_trace_to_out()
3984 if (res && w->bindas == -1) in hdaa_audio_trace_to_out()
3985 w->bindas = -2; in hdaa_audio_trace_to_out()
3988 device_printf(devinfo->dev, in hdaa_audio_trace_to_out()
3990 depth + 1, "", w->nid, res); in hdaa_audio_trace_to_out()
4001 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_trace_as_extra()
4009 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4012 for (j = devinfo->startnode; j < devinfo->endnode; j++) { in hdaa_audio_trace_as_extra()
4014 if (w == NULL || w->enable == 0) in hdaa_audio_trace_as_extra()
4016 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) in hdaa_audio_trace_as_extra()
4018 if (w->bindas < 0 || as[w->bindas].dir != HDAA_CTL_IN) in hdaa_audio_trace_as_extra()
4021 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4025 if (hdaa_audio_trace_to_out(devinfo, w->nid, 0)) { in hdaa_audio_trace_as_extra()
4027 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4029 w->nid); in hdaa_audio_trace_as_extra()
4031 w->ossdev = SOUND_MIXER_IMIX; in hdaa_audio_trace_as_extra()
4039 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4042 for (j = devinfo->startnode; j < devinfo->endnode; j++) { in hdaa_audio_trace_as_extra()
4044 if (w == NULL || w->enable == 0) in hdaa_audio_trace_as_extra()
4046 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_audio_trace_as_extra()
4048 if (w->bindas < 0 || as[w->bindas].dir != HDAA_CTL_IN) in hdaa_audio_trace_as_extra()
4051 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4055 if (hdaa_audio_trace_to_out(devinfo, w->nid, 0)) { in hdaa_audio_trace_as_extra()
4057 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4059 w->nid); in hdaa_audio_trace_as_extra()
4066 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4069 for (j = devinfo->startnode; j < devinfo->endnode; j++) { in hdaa_audio_trace_as_extra()
4071 if (w == NULL || w->enable == 0) in hdaa_audio_trace_as_extra()
4073 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_BEEP_WIDGET) in hdaa_audio_trace_as_extra()
4076 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4080 if (hdaa_audio_trace_to_out(devinfo, w->nid, 0)) { in hdaa_audio_trace_as_extra()
4082 device_printf(devinfo->dev, in hdaa_audio_trace_as_extra()
4087 w->bindas = -2; in hdaa_audio_trace_as_extra()
4097 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_bind_as()
4100 for (j = 0; j < devinfo->ascnt; j++) { in hdaa_audio_bind_as()
4104 if (devinfo->num_chans == 0) { in hdaa_audio_bind_as()
4105 devinfo->chans = malloc(sizeof(struct hdaa_chan) * cnt, in hdaa_audio_bind_as()
4107 if (devinfo->chans == NULL) { in hdaa_audio_bind_as()
4108 device_printf(devinfo->dev, in hdaa_audio_bind_as()
4113 devinfo->chans = (struct hdaa_chan *)realloc(devinfo->chans, in hdaa_audio_bind_as()
4114 sizeof(struct hdaa_chan) * (devinfo->num_chans + cnt), in hdaa_audio_bind_as()
4116 if (devinfo->chans == NULL) { in hdaa_audio_bind_as()
4117 devinfo->num_chans = 0; in hdaa_audio_bind_as()
4118 device_printf(devinfo->dev, in hdaa_audio_bind_as()
4123 for (j = 0; j < devinfo->num_chans; j++) in hdaa_audio_bind_as()
4124 devinfo->chans[j].caps.fmtlist = devinfo->chans[j].fmtlist; in hdaa_audio_bind_as()
4126 free = devinfo->num_chans; in hdaa_audio_bind_as()
4127 devinfo->num_chans += cnt; in hdaa_audio_bind_as()
4130 devinfo->chans[j].devinfo = devinfo; in hdaa_audio_bind_as()
4131 devinfo->chans[j].as = -1; in hdaa_audio_bind_as()
4135 for (j = 0; j < devinfo->ascnt; j++) { in hdaa_audio_bind_as()
4139 devinfo->chans[free].as = j; in hdaa_audio_bind_as()
4140 devinfo->chans[free].asindex = i; in hdaa_audio_bind_as()
4141 devinfo->chans[free].dir = in hdaa_audio_bind_as()
4143 hdaa_pcmchannel_setup(&devinfo->chans[free]); in hdaa_audio_bind_as()
4157 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_disable_nonaudio()
4159 if (w == NULL || w->enable == 0) in hdaa_audio_disable_nonaudio()
4161 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_POWER_WIDGET || in hdaa_audio_disable_nonaudio()
4162 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_VOLUME_WIDGET) { in hdaa_audio_disable_nonaudio()
4163 w->enable = 0; in hdaa_audio_disable_nonaudio()
4165 device_printf(devinfo->dev, in hdaa_audio_disable_nonaudio()
4167 " non-audio type.\n", in hdaa_audio_disable_nonaudio()
4168 w->nid); in hdaa_audio_disable_nonaudio()
4182 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_disable_useless()
4184 if (w == NULL || w->enable == 0) in hdaa_audio_disable_useless()
4186 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) { in hdaa_audio_disable_useless()
4187 if ((w->wclass.pin.config & in hdaa_audio_disable_useless()
4190 w->enable = 0; in hdaa_audio_disable_useless()
4192 device_printf(devinfo->dev, in hdaa_audio_disable_useless()
4195 w->nid); in hdaa_audio_disable_useless()
4197 } else if ((w->wclass.pin.config & in hdaa_audio_disable_useless()
4199 w->enable = 0; in hdaa_audio_disable_useless()
4201 device_printf(devinfo->dev, in hdaa_audio_disable_useless()
4204 w->nid); in hdaa_audio_disable_useless()
4214 if (ctl->enable == 0) in hdaa_audio_disable_useless()
4216 if (ctl->widget->enable == 0 || in hdaa_audio_disable_useless()
4217 (ctl->childwidget != NULL && in hdaa_audio_disable_useless()
4218 ctl->childwidget->enable == 0)) { in hdaa_audio_disable_useless()
4219 ctl->forcemute = 1; in hdaa_audio_disable_useless()
4220 ctl->muted = HDAA_AMP_MUTE_ALL; in hdaa_audio_disable_useless()
4221 ctl->left = 0; in hdaa_audio_disable_useless()
4222 ctl->right = 0; in hdaa_audio_disable_useless()
4223 ctl->enable = 0; in hdaa_audio_disable_useless()
4224 if (ctl->ndir == HDAA_CTL_IN) in hdaa_audio_disable_useless()
4225 ctl->widget->connsenable[ctl->index] = 0; in hdaa_audio_disable_useless()
4228 device_printf(devinfo->dev, in hdaa_audio_disable_useless()
4231 ctl->widget->nid, in hdaa_audio_disable_useless()
4232 (ctl->childwidget != NULL)? in hdaa_audio_disable_useless()
4233 ctl->childwidget->nid:-1); in hdaa_audio_disable_useless()
4238 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_disable_useless()
4240 if (w == NULL || w->enable == 0) in hdaa_audio_disable_useless()
4243 for (j = 0; j < w->nconns; j++) { in hdaa_audio_disable_useless()
4244 if (w->connsenable[j]) { in hdaa_audio_disable_useless()
4245 cw = hdaa_widget_get(devinfo, w->conns[j]); in hdaa_audio_disable_useless()
4246 if (cw == NULL || cw->enable == 0) { in hdaa_audio_disable_useless()
4247 w->connsenable[j] = 0; in hdaa_audio_disable_useless()
4249 device_printf(devinfo->dev, in hdaa_audio_disable_useless()
4257 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR && in hdaa_audio_disable_useless()
4258 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) in hdaa_audio_disable_useless()
4262 for (j = 0; j < w->nconns; j++) { in hdaa_audio_disable_useless()
4263 if (w->connsenable[j]) { in hdaa_audio_disable_useless()
4269 w->enable = 0; in hdaa_audio_disable_useless()
4272 device_printf(devinfo->dev, in hdaa_audio_disable_useless()
4274 " inputs disabled.\n", w->nid); in hdaa_audio_disable_useless()
4278 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_SELECTOR && in hdaa_audio_disable_useless()
4279 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) in hdaa_audio_disable_useless()
4282 for (k = devinfo->startnode; k < devinfo->endnode; k++) { in hdaa_audio_disable_useless()
4284 if (cw == NULL || cw->enable == 0) in hdaa_audio_disable_useless()
4286 for (j = 0; j < cw->nconns; j++) { in hdaa_audio_disable_useless()
4287 if (cw->connsenable[j] && cw->conns[j] == i) { in hdaa_audio_disable_useless()
4294 w->enable = 0; in hdaa_audio_disable_useless()
4297 device_printf(devinfo->dev, in hdaa_audio_disable_useless()
4299 " consumers disabled.\n", w->nid); in hdaa_audio_disable_useless()
4310 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_disable_unas()
4316 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_disable_unas()
4318 if (w == NULL || w->enable == 0) in hdaa_audio_disable_unas()
4320 if (w->bindas == -1) { in hdaa_audio_disable_unas()
4321 w->enable = 0; in hdaa_audio_disable_unas()
4323 device_printf(devinfo->dev, in hdaa_audio_disable_unas()
4325 w->nid); in hdaa_audio_disable_unas()
4331 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_disable_unas()
4333 if (w == NULL || w->enable == 0) in hdaa_audio_disable_unas()
4335 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_audio_disable_unas()
4337 if (w->bindas < 0) in hdaa_audio_disable_unas()
4339 if (as[w->bindas].dir == HDAA_CTL_IN) { in hdaa_audio_disable_unas()
4340 for (j = 0; j < w->nconns; j++) { in hdaa_audio_disable_unas()
4341 if (w->connsenable[j] == 0) in hdaa_audio_disable_unas()
4343 w->connsenable[j] = 0; in hdaa_audio_disable_unas()
4345 device_printf(devinfo->dev, in hdaa_audio_disable_unas()
4351 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, in hdaa_audio_disable_unas()
4352 HDAA_CTL_IN, -1, 1); in hdaa_audio_disable_unas()
4353 if (ctl && ctl->enable) { in hdaa_audio_disable_unas()
4354 ctl->forcemute = 1; in hdaa_audio_disable_unas()
4355 ctl->muted = HDAA_AMP_MUTE_ALL; in hdaa_audio_disable_unas()
4356 ctl->left = 0; in hdaa_audio_disable_unas()
4357 ctl->right = 0; in hdaa_audio_disable_unas()
4358 ctl->enable = 0; in hdaa_audio_disable_unas()
4361 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, in hdaa_audio_disable_unas()
4362 HDAA_CTL_OUT, -1, 1); in hdaa_audio_disable_unas()
4363 if (ctl && ctl->enable) { in hdaa_audio_disable_unas()
4364 ctl->forcemute = 1; in hdaa_audio_disable_unas()
4365 ctl->muted = HDAA_AMP_MUTE_ALL; in hdaa_audio_disable_unas()
4366 ctl->left = 0; in hdaa_audio_disable_unas()
4367 ctl->right = 0; in hdaa_audio_disable_unas()
4368 ctl->enable = 0; in hdaa_audio_disable_unas()
4370 for (k = devinfo->startnode; k < devinfo->endnode; k++) { in hdaa_audio_disable_unas()
4372 if (cw == NULL || cw->enable == 0) in hdaa_audio_disable_unas()
4374 for (j = 0; j < cw->nconns; j++) { in hdaa_audio_disable_unas()
4375 if (cw->connsenable[j] && cw->conns[j] == i) { in hdaa_audio_disable_unas()
4376 cw->connsenable[j] = 0; in hdaa_audio_disable_unas()
4378 device_printf(devinfo->dev, in hdaa_audio_disable_unas()
4383 if (cw->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX && in hdaa_audio_disable_unas()
4384 cw->nconns > 1) in hdaa_audio_disable_unas()
4388 if (ctl && ctl->enable) { in hdaa_audio_disable_unas()
4389 ctl->forcemute = 1; in hdaa_audio_disable_unas()
4390 ctl->muted = HDAA_AMP_MUTE_ALL; in hdaa_audio_disable_unas()
4391 ctl->left = 0; in hdaa_audio_disable_unas()
4392 ctl->right = 0; in hdaa_audio_disable_unas()
4393 ctl->enable = 0; in hdaa_audio_disable_unas()
4405 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_disable_notselected()
4410 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_disable_notselected()
4412 if (w == NULL || w->enable == 0) in hdaa_audio_disable_notselected()
4414 if (w->nconns <= 1) in hdaa_audio_disable_notselected()
4416 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) in hdaa_audio_disable_notselected()
4418 if (w->bindas < 0 || as[w->bindas].dir == HDAA_CTL_IN) in hdaa_audio_disable_notselected()
4420 for (j = 0; j < w->nconns; j++) { in hdaa_audio_disable_notselected()
4421 if (w->connsenable[j] == 0) in hdaa_audio_disable_notselected()
4423 if (w->selconn < 0 || w->selconn == j) in hdaa_audio_disable_notselected()
4425 w->connsenable[j] = 0; in hdaa_audio_disable_notselected()
4427 device_printf(devinfo->dev, in hdaa_audio_disable_notselected()
4439 struct hdaa_audio_as *ases = devinfo->as; in hdaa_audio_disable_crossas()
4446 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_disable_crossas()
4448 if (w == NULL || w->enable == 0) in hdaa_audio_disable_crossas()
4450 if (w->nconns <= 1) in hdaa_audio_disable_crossas()
4452 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) in hdaa_audio_disable_crossas()
4454 /* Allow any -> mix */ in hdaa_audio_disable_crossas()
4455 if (w->bindas == -2) in hdaa_audio_disable_crossas()
4457 for (j = 0; j < w->nconns; j++) { in hdaa_audio_disable_crossas()
4458 if (w->connsenable[j] == 0) in hdaa_audio_disable_crossas()
4460 cw = hdaa_widget_get(devinfo, w->conns[j]); in hdaa_audio_disable_crossas()
4461 if (cw == NULL || w->enable == 0) in hdaa_audio_disable_crossas()
4463 /* Allow mix -> out. */ in hdaa_audio_disable_crossas()
4464 if (cw->bindas == -2 && w->bindas >= 0 && in hdaa_audio_disable_crossas()
4465 ases[w->bindas].dir == HDAA_CTL_OUT) in hdaa_audio_disable_crossas()
4467 /* Allow mix -> mixed-in. */ in hdaa_audio_disable_crossas()
4468 if (cw->bindas == -2 && w->bindas >= 0 && in hdaa_audio_disable_crossas()
4469 ases[w->bindas].mixed) in hdaa_audio_disable_crossas()
4471 /* Allow in -> mix. */ in hdaa_audio_disable_crossas()
4472 if ((w->pflags & HDAA_ADC_MONITOR) && in hdaa_audio_disable_crossas()
4473 cw->bindas >= 0 && in hdaa_audio_disable_crossas()
4474 ases[cw->bindas].dir == HDAA_CTL_IN) in hdaa_audio_disable_crossas()
4477 if (w->bindas == cw->bindas && in hdaa_audio_disable_crossas()
4478 (w->bindseqmask & cw->bindseqmask) != 0) in hdaa_audio_disable_crossas()
4480 w->connsenable[j] = 0; in hdaa_audio_disable_crossas()
4482 device_printf(devinfo->dev, in hdaa_audio_disable_crossas()
4485 i, j, cw->nid); in hdaa_audio_disable_crossas()
4492 if (ctl->enable == 0 || ctl->childwidget == NULL) in hdaa_audio_disable_crossas()
4494 /* Allow any -> mix */ in hdaa_audio_disable_crossas()
4495 if (ctl->widget->bindas == -2) in hdaa_audio_disable_crossas()
4497 /* Allow mix -> out. */ in hdaa_audio_disable_crossas()
4498 if (ctl->childwidget->bindas == -2 && in hdaa_audio_disable_crossas()
4499 ctl->widget->bindas >= 0 && in hdaa_audio_disable_crossas()
4500 ases[ctl->widget->bindas].dir == HDAA_CTL_OUT) in hdaa_audio_disable_crossas()
4502 /* Allow mix -> mixed-in. */ in hdaa_audio_disable_crossas()
4503 if (ctl->childwidget->bindas == -2 && in hdaa_audio_disable_crossas()
4504 ctl->widget->bindas >= 0 && in hdaa_audio_disable_crossas()
4505 ases[ctl->widget->bindas].mixed) in hdaa_audio_disable_crossas()
4507 /* Allow in -> mix. */ in hdaa_audio_disable_crossas()
4508 if ((ctl->widget->pflags & HDAA_ADC_MONITOR) && in hdaa_audio_disable_crossas()
4509 ctl->childwidget->bindas >= 0 && in hdaa_audio_disable_crossas()
4510 ases[ctl->childwidget->bindas].dir == HDAA_CTL_IN) in hdaa_audio_disable_crossas()
4513 if (ctl->widget->bindas == ctl->childwidget->bindas && in hdaa_audio_disable_crossas()
4514 (ctl->widget->bindseqmask & ctl->childwidget->bindseqmask) != 0) in hdaa_audio_disable_crossas()
4516 ctl->forcemute = 1; in hdaa_audio_disable_crossas()
4517 ctl->muted = HDAA_AMP_MUTE_ALL; in hdaa_audio_disable_crossas()
4518 ctl->left = 0; in hdaa_audio_disable_crossas()
4519 ctl->right = 0; in hdaa_audio_disable_crossas()
4520 ctl->enable = 0; in hdaa_audio_disable_crossas()
4521 if (ctl->ndir == HDAA_CTL_IN) in hdaa_audio_disable_crossas()
4522 ctl->widget->connsenable[ctl->index] = 0; in hdaa_audio_disable_crossas()
4524 device_printf(devinfo->dev, in hdaa_audio_disable_crossas()
4527 ctl->widget->nid, in hdaa_audio_disable_crossas()
4528 ctl->childwidget->nid); in hdaa_audio_disable_crossas()
4550 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_source_amp()
4555 for (j = 0; j < w->nconns; j++) { in hdaa_audio_ctl_source_amp()
4556 if (!w->connsenable[j]) in hdaa_audio_ctl_source_amp()
4562 /* If this is not a first step - use input mixer. in hdaa_audio_ctl_source_amp()
4565 w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)) { in hdaa_audio_ctl_source_amp()
4566 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, HDAA_CTL_IN, in hdaa_audio_ctl_source_amp()
4569 ctl->ossmask |= (1 << ossdev); in hdaa_audio_ctl_source_amp()
4578 /* If widget has own ossdev - not traverse it. in hdaa_audio_ctl_source_amp()
4580 if (w->ossdev >= 0 && depth > 0) in hdaa_audio_ctl_source_amp()
4584 if ((w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT || in hdaa_audio_ctl_source_amp()
4585 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) && in hdaa_audio_ctl_source_amp()
4590 w->ossmask |= (1 << ossdev); in hdaa_audio_ctl_source_amp()
4597 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_MIXER) in hdaa_audio_ctl_source_amp()
4601 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, HDAA_CTL_OUT, -1, 1); in hdaa_audio_ctl_source_amp()
4603 ctl->ossmask |= (1 << ossdev); in hdaa_audio_ctl_source_amp()
4613 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_ctl_source_amp()
4615 if (wc == NULL || wc->enable == 0) in hdaa_audio_ctl_source_amp()
4617 for (j = 0; j < wc->nconns; j++) { in hdaa_audio_ctl_source_amp()
4618 if (wc->connsenable[j] && wc->conns[j] == nid) { in hdaa_audio_ctl_source_amp()
4621 wc->nid, j, ossdev, ctlable, depth + 1, in hdaa_audio_ctl_source_amp()
4648 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_ctl_dest_amp()
4657 if (w == NULL || w->enable == 0) in hdaa_audio_ctl_dest_amp()
4664 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_ctl_dest_amp()
4666 if (wc == NULL || wc->enable == 0) in hdaa_audio_ctl_dest_amp()
4668 for (j = 0; j < wc->nconns; j++) { in hdaa_audio_ctl_dest_amp()
4669 if (wc->connsenable[j] && wc->conns[j] == nid) in hdaa_audio_ctl_dest_amp()
4677 if ((consumers == 2 && (w->bindas < 0 || in hdaa_audio_ctl_dest_amp()
4678 as[w->bindas].hpredir < 0 || as[w->bindas].fakeredir || in hdaa_audio_ctl_dest_amp()
4679 (w->bindseqmask & (1 << 15)) == 0)) || in hdaa_audio_ctl_dest_amp()
4684 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, in hdaa_audio_ctl_dest_amp()
4685 HDAA_CTL_OUT, -1, 1); in hdaa_audio_ctl_dest_amp()
4687 ctl->ossmask |= (1 << ossdev); in hdaa_audio_ctl_dest_amp()
4697 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX && in hdaa_audio_ctl_dest_amp()
4702 for (i = 0; i < w->nconns; i++) { in hdaa_audio_ctl_dest_amp()
4703 if (w->connsenable[i] == 0) in hdaa_audio_ctl_dest_amp()
4708 ctl = hdaa_audio_ctl_amp_get(devinfo, w->nid, in hdaa_audio_ctl_dest_amp()
4711 ctl->ossmask |= (1 << ossdev); in hdaa_audio_ctl_dest_amp()
4718 found += hdaa_audio_ctl_dest_amp(devinfo, w->conns[i], -1, ossdev, in hdaa_audio_ctl_dest_amp()
4741 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_assign_names()
4744 int type = -1, use, used = 0; in hdaa_audio_assign_names()
4747 SOUND_MIXER_LINE3, -1 }, /* line */ in hdaa_audio_assign_names()
4748 { SOUND_MIXER_MONITOR, SOUND_MIXER_MIC, -1 }, /* int mic */ in hdaa_audio_assign_names()
4749 { SOUND_MIXER_MIC, SOUND_MIXER_MONITOR, -1 }, /* ext mic */ in hdaa_audio_assign_names()
4750 { SOUND_MIXER_CD, -1 }, /* cd */ in hdaa_audio_assign_names()
4751 { SOUND_MIXER_SPEAKER, -1 }, /* speaker */ in hdaa_audio_assign_names()
4753 -1 }, /* digital */ in hdaa_audio_assign_names()
4758 -1 } /* others */ in hdaa_audio_assign_names()
4762 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_assign_names()
4764 if (w == NULL || w->enable == 0) in hdaa_audio_assign_names()
4766 if (w->bindas == -1) in hdaa_audio_assign_names()
4768 use = -1; in hdaa_audio_assign_names()
4769 switch (w->type) { in hdaa_audio_assign_names()
4771 if (as[w->bindas].dir == HDAA_CTL_OUT) in hdaa_audio_assign_names()
4773 type = -1; in hdaa_audio_assign_names()
4774 switch (w->wclass.pin.config & HDA_CONFIG_DEFAULTCONF_DEVICE_MASK) { in hdaa_audio_assign_names()
4779 if ((w->wclass.pin.config & HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK) in hdaa_audio_assign_names()
4795 if (type == -1) in hdaa_audio_assign_names()
4815 w->ossdev = use; in hdaa_audio_assign_names()
4819 /* Semi-known names */ in hdaa_audio_assign_names()
4820 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_assign_names()
4822 if (w == NULL || w->enable == 0) in hdaa_audio_assign_names()
4824 if (w->ossdev >= 0) in hdaa_audio_assign_names()
4826 if (w->bindas == -1) in hdaa_audio_assign_names()
4828 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_audio_assign_names()
4830 if (as[w->bindas].dir == HDAA_CTL_OUT) in hdaa_audio_assign_names()
4832 type = -1; in hdaa_audio_assign_names()
4833 switch (w->wclass.pin.config & HDA_CONFIG_DEFAULTCONF_DEVICE_MASK) { in hdaa_audio_assign_names()
4848 if (type == -1) in hdaa_audio_assign_names()
4856 w->ossdev = types[type][j]; in hdaa_audio_assign_names()
4861 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_assign_names()
4863 if (w == NULL || w->enable == 0) in hdaa_audio_assign_names()
4865 if (w->ossdev >= 0) in hdaa_audio_assign_names()
4867 if (w->bindas == -1) in hdaa_audio_assign_names()
4869 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_audio_assign_names()
4871 if (as[w->bindas].dir == HDAA_CTL_OUT) in hdaa_audio_assign_names()
4879 w->ossdev = types[6][j]; in hdaa_audio_assign_names()
4888 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_build_tree()
4892 for (j = 0; j < devinfo->ascnt; j++) { in hdaa_audio_build_tree()
4896 device_printf(devinfo->dev, in hdaa_audio_build_tree()
4915 device_printf(devinfo->dev, in hdaa_audio_build_tree()
4921 device_printf(devinfo->dev, in hdaa_audio_build_tree()
4930 for (j = 0; j < devinfo->ascnt; j++) { in hdaa_audio_build_tree()
4948 struct hdaa_devinfo *devinfo = w->devinfo; in hdaa_adjust_amp()
4951 if (w->bindas >= 0) in hdaa_adjust_amp()
4952 pdevinfo = devinfo->as[w->bindas].pdevinfo; in hdaa_adjust_amp()
4954 pdevinfo = &devinfo->devs[0]; in hdaa_adjust_amp()
4956 pdevinfo->ossmask |= (1 << ossdev); in hdaa_adjust_amp()
4959 if (pdevinfo->minamp[ossdev] == 0 && pdevinfo->maxamp[ossdev] == 0) { in hdaa_adjust_amp()
4960 pdevinfo->minamp[ossdev] = minamp; in hdaa_adjust_amp()
4961 pdevinfo->maxamp[ossdev] = maxamp; in hdaa_adjust_amp()
4963 pdevinfo->minamp[ossdev] = imax(pdevinfo->minamp[ossdev], minamp); in hdaa_adjust_amp()
4964 pdevinfo->maxamp[ossdev] = imin(pdevinfo->maxamp[ossdev], maxamp); in hdaa_adjust_amp()
4975 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_assign_mixers()
4980 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_audio_assign_mixers()
4982 if (w == NULL || w->enable == 0) in hdaa_audio_assign_mixers()
4985 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT || in hdaa_audio_assign_mixers()
4986 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_BEEP_WIDGET || in hdaa_audio_assign_mixers()
4987 (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX && in hdaa_audio_assign_mixers()
4988 as[w->bindas].dir == HDAA_CTL_IN)) { in hdaa_audio_assign_mixers()
4989 if (w->ossdev < 0) in hdaa_audio_assign_mixers()
4991 found = hdaa_audio_ctl_source_amp(devinfo, w->nid, -1, in hdaa_audio_assign_mixers()
4992 w->ossdev, 1, 0, &minamp, &maxamp); in hdaa_audio_assign_mixers()
4993 hdaa_adjust_amp(w, w->ossdev, found, minamp, maxamp); in hdaa_audio_assign_mixers()
4994 } else if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) { in hdaa_audio_assign_mixers()
4995 found = hdaa_audio_ctl_dest_amp(devinfo, w->nid, -1, in hdaa_audio_assign_mixers()
4998 } else if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX && in hdaa_audio_assign_mixers()
4999 as[w->bindas].dir == HDAA_CTL_OUT) { in hdaa_audio_assign_mixers()
5000 found = hdaa_audio_ctl_dest_amp(devinfo, w->nid, -1, in hdaa_audio_assign_mixers()
5004 if (w->ossdev == SOUND_MIXER_IMIX) { in hdaa_audio_assign_mixers()
5006 found = hdaa_audio_ctl_source_amp(devinfo, w->nid, -1, in hdaa_audio_assign_mixers()
5007 w->ossdev, 1, 0, &minamp, &maxamp); in hdaa_audio_assign_mixers()
5010 as source - try to control it as destination. */ in hdaa_audio_assign_mixers()
5011 found += hdaa_audio_ctl_dest_amp(devinfo, w->nid, -1, in hdaa_audio_assign_mixers()
5012 w->ossdev, 0, &minamp, &maxamp); in hdaa_audio_assign_mixers()
5013 w->pflags |= HDAA_IMIX_AS_DST; in hdaa_audio_assign_mixers()
5015 hdaa_adjust_amp(w, w->ossdev, found, minamp, maxamp); in hdaa_audio_assign_mixers()
5017 if (w->pflags & HDAA_ADC_MONITOR) { in hdaa_audio_assign_mixers()
5018 for (j = 0; j < w->nconns; j++) { in hdaa_audio_assign_mixers()
5019 if (!w->connsenable[j]) in hdaa_audio_assign_mixers()
5021 cw = hdaa_widget_get(devinfo, w->conns[j]); in hdaa_audio_assign_mixers()
5022 if (cw == NULL || cw->enable == 0) in hdaa_audio_assign_mixers()
5024 if (cw->bindas == -1) in hdaa_audio_assign_mixers()
5026 if (cw->bindas >= 0 && in hdaa_audio_assign_mixers()
5027 as[cw->bindas].dir != HDAA_CTL_IN) in hdaa_audio_assign_mixers()
5031 w->nid, j, SOUND_MIXER_IGAIN, 0, in hdaa_audio_assign_mixers()
5043 struct hdaa_audio_as *as = devinfo->as; in hdaa_audio_prepare_pin_ctrl()
5048 for (i = 0; i < devinfo->nodecnt; i++) { in hdaa_audio_prepare_pin_ctrl()
5049 w = &devinfo->widget[i]; in hdaa_audio_prepare_pin_ctrl()
5052 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX && in hdaa_audio_prepare_pin_ctrl()
5053 w->waspin == 0) in hdaa_audio_prepare_pin_ctrl()
5056 pincap = w->wclass.pin.cap; in hdaa_audio_prepare_pin_ctrl()
5059 if (devinfo->init_clear) { in hdaa_audio_prepare_pin_ctrl()
5060 w->wclass.pin.ctrl &= ~( in hdaa_audio_prepare_pin_ctrl()
5067 if (w->enable == 0) { in hdaa_audio_prepare_pin_ctrl()
5070 } else if (w->waspin) { in hdaa_audio_prepare_pin_ctrl()
5072 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5074 } else if (w->bindas < 0 || as[w->bindas].enable == 0) { in hdaa_audio_prepare_pin_ctrl()
5077 } else if (as[w->bindas].dir == HDAA_CTL_IN) { in hdaa_audio_prepare_pin_ctrl()
5080 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5083 if ((devinfo->quirks & HDAA_QUIRK_IVREF100) && in hdaa_audio_prepare_pin_ctrl()
5085 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5088 else if ((devinfo->quirks & HDAA_QUIRK_IVREF80) && in hdaa_audio_prepare_pin_ctrl()
5090 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5093 else if ((devinfo->quirks & HDAA_QUIRK_IVREF50) && in hdaa_audio_prepare_pin_ctrl()
5095 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5101 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5105 (w->wclass.pin.config & in hdaa_audio_prepare_pin_ctrl()
5108 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5111 if ((devinfo->quirks & HDAA_QUIRK_OVREF100) && in hdaa_audio_prepare_pin_ctrl()
5113 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5116 else if ((devinfo->quirks & HDAA_QUIRK_OVREF80) && in hdaa_audio_prepare_pin_ctrl()
5118 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5121 else if ((devinfo->quirks & HDAA_QUIRK_OVREF50) && in hdaa_audio_prepare_pin_ctrl()
5123 w->wclass.pin.ctrl |= in hdaa_audio_prepare_pin_ctrl()
5138 if (ctl->enable == 0 || ctl->ossmask != 0) { in hdaa_audio_ctl_commit()
5146 z = ctl->offset; in hdaa_audio_ctl_commit()
5147 if (z > ctl->step) in hdaa_audio_ctl_commit()
5148 z = ctl->step; in hdaa_audio_ctl_commit()
5159 numgpio = HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap); in hdaa_gpio_commit()
5160 if (devinfo->gpio != 0 && numgpio != 0) { in hdaa_gpio_commit()
5161 gdata = hda_command(devinfo->dev, in hdaa_gpio_commit()
5162 HDA_CMD_GET_GPIO_DATA(0, devinfo->nid)); in hdaa_gpio_commit()
5163 gmask = hda_command(devinfo->dev, in hdaa_gpio_commit()
5164 HDA_CMD_GET_GPIO_ENABLE_MASK(0, devinfo->nid)); in hdaa_gpio_commit()
5165 gdir = hda_command(devinfo->dev, in hdaa_gpio_commit()
5166 HDA_CMD_GET_GPIO_DIRECTION(0, devinfo->nid)); in hdaa_gpio_commit()
5168 if ((devinfo->gpio & HDAA_GPIO_MASK(i)) == in hdaa_gpio_commit()
5173 } else if ((devinfo->gpio & HDAA_GPIO_MASK(i)) == in hdaa_gpio_commit()
5178 } else if ((devinfo->gpio & HDAA_GPIO_MASK(i)) == in hdaa_gpio_commit()
5181 } else if ((devinfo->gpio & HDAA_GPIO_MASK(i)) == in hdaa_gpio_commit()
5188 device_printf(devinfo->dev, "GPIO commit\n"); in hdaa_gpio_commit()
5190 hda_command(devinfo->dev, in hdaa_gpio_commit()
5191 HDA_CMD_SET_GPIO_ENABLE_MASK(0, devinfo->nid, gmask)); in hdaa_gpio_commit()
5192 hda_command(devinfo->dev, in hdaa_gpio_commit()
5193 HDA_CMD_SET_GPIO_DIRECTION(0, devinfo->nid, gdir)); in hdaa_gpio_commit()
5194 hda_command(devinfo->dev, in hdaa_gpio_commit()
5195 HDA_CMD_SET_GPIO_DATA(0, devinfo->nid, gdata)); in hdaa_gpio_commit()
5208 numgpo = HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap); in hdaa_gpo_commit()
5209 if (devinfo->gpo != 0 && numgpo != 0) { in hdaa_gpo_commit()
5210 gdata = hda_command(devinfo->dev, in hdaa_gpo_commit()
5211 HDA_CMD_GET_GPO_DATA(0, devinfo->nid)); in hdaa_gpo_commit()
5213 if ((devinfo->gpio & HDAA_GPIO_MASK(i)) == in hdaa_gpo_commit()
5216 } else if ((devinfo->gpio & HDAA_GPIO_MASK(i)) == in hdaa_gpo_commit()
5222 device_printf(devinfo->dev, "GPO commit\n"); in hdaa_gpo_commit()
5224 hda_command(devinfo->dev, in hdaa_gpo_commit()
5225 HDA_CMD_SET_GPO_DATA(0, devinfo->nid, gdata)); in hdaa_gpo_commit()
5242 for (i = 0; i < devinfo->nodecnt; i++) { in hdaa_audio_commit()
5243 w = &devinfo->widget[i]; in hdaa_audio_commit()
5246 if (w->selconn == -1) in hdaa_audio_commit()
5247 w->selconn = 0; in hdaa_audio_commit()
5248 if (w->nconns > 0) in hdaa_audio_commit()
5249 hdaa_widget_connection_select(w, w->selconn); in hdaa_audio_commit()
5250 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || in hdaa_audio_commit()
5251 w->waspin) { in hdaa_audio_commit()
5252 hda_command(devinfo->dev, in hdaa_audio_commit()
5253 HDA_CMD_SET_PIN_WIDGET_CTRL(0, w->nid, in hdaa_audio_commit()
5254 w->wclass.pin.ctrl)); in hdaa_audio_commit()
5256 if (w->param.eapdbtl != HDA_INVALID) { in hdaa_audio_commit()
5259 val = w->param.eapdbtl; in hdaa_audio_commit()
5260 if (devinfo->quirks & in hdaa_audio_commit()
5263 hda_command(devinfo->dev, in hdaa_audio_commit()
5264 HDA_CMD_SET_EAPD_BTL_ENABLE(0, w->nid, in hdaa_audio_commit()
5278 hda_command(devinfo->dev, in hdaa_powerup()
5280 devinfo->nid, HDA_CMD_POWER_STATE_D0)); in hdaa_powerup()
5283 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_powerup()
5284 hda_command(devinfo->dev, in hdaa_powerup()
5294 struct hdaa_devinfo *devinfo = ch->devinfo; in hdaa_pcmchannel_setup()
5295 struct hdaa_audio_as *as = devinfo->as; in hdaa_pcmchannel_setup()
5301 ch->caps = hdaa_caps; in hdaa_pcmchannel_setup()
5302 ch->caps.fmtlist = ch->fmtlist; in hdaa_pcmchannel_setup()
5303 ch->bit16 = 1; in hdaa_pcmchannel_setup()
5304 ch->bit32 = 0; in hdaa_pcmchannel_setup()
5305 ch->pcmrates[0] = 48000; in hdaa_pcmchannel_setup()
5306 ch->pcmrates[1] = 0; in hdaa_pcmchannel_setup()
5307 ch->stripecap = 0xff; in hdaa_pcmchannel_setup()
5313 fmtcap = devinfo->supp_stream_formats; in hdaa_pcmchannel_setup()
5314 pcmcap = devinfo->supp_pcm_size_rate; in hdaa_pcmchannel_setup()
5318 if (ch->as < 0) in hdaa_pcmchannel_setup()
5321 if (as[ch->as].dacs[ch->asindex][i] <= 0) in hdaa_pcmchannel_setup()
5325 if (ch->io[j] == as[ch->as].dacs[ch->asindex][i]) in hdaa_pcmchannel_setup()
5331 w = hdaa_widget_get(devinfo, as[ch->as].dacs[ch->asindex][i]); in hdaa_pcmchannel_setup()
5332 if (w == NULL || w->enable == 0) in hdaa_pcmchannel_setup()
5334 cap = w->param.supp_stream_formats; in hdaa_pcmchannel_setup()
5340 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) in hdaa_pcmchannel_setup()
5344 pcmcap = w->param.supp_pcm_size_rate; in hdaa_pcmchannel_setup()
5347 pcmcap &= w->param.supp_pcm_size_rate; in hdaa_pcmchannel_setup()
5349 ch->io[ret++] = as[ch->as].dacs[ch->asindex][i]; in hdaa_pcmchannel_setup()
5350 ch->stripecap &= w->wclass.conv.stripecap; in hdaa_pcmchannel_setup()
5352 if (i == 15 && as[ch->as].hpredir >= 0) in hdaa_pcmchannel_setup()
5354 channels += HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap) + 1; in hdaa_pcmchannel_setup()
5355 if (HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap) != 1) in hdaa_pcmchannel_setup()
5359 ch->io[ret] = -1; in hdaa_pcmchannel_setup()
5360 ch->channels = channels; in hdaa_pcmchannel_setup()
5362 if (as[ch->as].fakeredir) in hdaa_pcmchannel_setup()
5363 ret--; in hdaa_pcmchannel_setup()
5365 if ((!onlystereo) || as[ch->as].mixed) in hdaa_pcmchannel_setup()
5368 as[ch->as].pinset = pinset; in hdaa_pcmchannel_setup()
5370 ch->supp_stream_formats = fmtcap; in hdaa_pcmchannel_setup()
5371 ch->supp_pcm_size_rate = pcmcap; in hdaa_pcmchannel_setup()
5384 ch->bit16 = 1; in hdaa_pcmchannel_setup()
5386 ch->bit16 = 0; in hdaa_pcmchannel_setup()
5388 ch->bit32 = 3; in hdaa_pcmchannel_setup()
5390 ch->bit32 = 2; in hdaa_pcmchannel_setup()
5392 ch->bit32 = 4; in hdaa_pcmchannel_setup()
5393 if (!(devinfo->quirks & HDAA_QUIRK_FORCESTEREO)) { in hdaa_pcmchannel_setup()
5394 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 1, 0); in hdaa_pcmchannel_setup()
5395 if (ch->bit32) in hdaa_pcmchannel_setup()
5396 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 1, 0); in hdaa_pcmchannel_setup()
5399 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 2, 0); in hdaa_pcmchannel_setup()
5400 if (ch->bit32) in hdaa_pcmchannel_setup()
5401 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 2, 0); in hdaa_pcmchannel_setup()
5404 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 3, 0); in hdaa_pcmchannel_setup()
5405 if (ch->bit32) in hdaa_pcmchannel_setup()
5406 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 3, 0); in hdaa_pcmchannel_setup()
5407 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 3, 1); in hdaa_pcmchannel_setup()
5408 if (ch->bit32) in hdaa_pcmchannel_setup()
5409 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 3, 1); in hdaa_pcmchannel_setup()
5412 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 4, 0); in hdaa_pcmchannel_setup()
5413 if (ch->bit32) in hdaa_pcmchannel_setup()
5414 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 4, 0); in hdaa_pcmchannel_setup()
5416 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 4, 1); in hdaa_pcmchannel_setup()
5417 if (ch->bit32) in hdaa_pcmchannel_setup()
5418 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 4, 1); in hdaa_pcmchannel_setup()
5422 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 5, 0); in hdaa_pcmchannel_setup()
5423 if (ch->bit32) in hdaa_pcmchannel_setup()
5424 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 5, 0); in hdaa_pcmchannel_setup()
5425 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 5, 1); in hdaa_pcmchannel_setup()
5426 if (ch->bit32) in hdaa_pcmchannel_setup()
5427 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 5, 1); in hdaa_pcmchannel_setup()
5430 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 6, 1); in hdaa_pcmchannel_setup()
5431 if (ch->bit32) in hdaa_pcmchannel_setup()
5432 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 6, 1); in hdaa_pcmchannel_setup()
5434 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 6, 0); in hdaa_pcmchannel_setup()
5435 if (ch->bit32) in hdaa_pcmchannel_setup()
5436 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 6, 0); in hdaa_pcmchannel_setup()
5440 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 7, 0); in hdaa_pcmchannel_setup()
5441 if (ch->bit32) in hdaa_pcmchannel_setup()
5442 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 7, 0); in hdaa_pcmchannel_setup()
5443 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 7, 1); in hdaa_pcmchannel_setup()
5444 if (ch->bit32) in hdaa_pcmchannel_setup()
5445 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 7, 1); in hdaa_pcmchannel_setup()
5448 ch->fmtlist[i++] = SND_FORMAT(AFMT_S16_LE, 8, 1); in hdaa_pcmchannel_setup()
5449 if (ch->bit32) in hdaa_pcmchannel_setup()
5450 ch->fmtlist[i++] = SND_FORMAT(AFMT_S32_LE, 8, 1); in hdaa_pcmchannel_setup()
5454 ch->fmtlist[i++] = SND_FORMAT(AFMT_AC3, 2, 0); in hdaa_pcmchannel_setup()
5456 ch->fmtlist[i++] = SND_FORMAT(AFMT_AC3, 8, 1); in hdaa_pcmchannel_setup()
5459 ch->fmtlist[i] = 0; in hdaa_pcmchannel_setup()
5462 ch->pcmrates[i++] = 8000; in hdaa_pcmchannel_setup()
5464 ch->pcmrates[i++] = 11025; in hdaa_pcmchannel_setup()
5466 ch->pcmrates[i++] = 16000; in hdaa_pcmchannel_setup()
5468 ch->pcmrates[i++] = 22050; in hdaa_pcmchannel_setup()
5470 ch->pcmrates[i++] = 32000; in hdaa_pcmchannel_setup()
5472 ch->pcmrates[i++] = 44100; in hdaa_pcmchannel_setup()
5474 ch->pcmrates[i++] = 48000; in hdaa_pcmchannel_setup()
5476 ch->pcmrates[i++] = 88200; in hdaa_pcmchannel_setup()
5478 ch->pcmrates[i++] = 96000; in hdaa_pcmchannel_setup()
5480 ch->pcmrates[i++] = 176400; in hdaa_pcmchannel_setup()
5482 ch->pcmrates[i++] = 192000; in hdaa_pcmchannel_setup()
5484 ch->pcmrates[i] = 0; in hdaa_pcmchannel_setup()
5486 ch->caps.minspeed = ch->pcmrates[0]; in hdaa_pcmchannel_setup()
5487 ch->caps.maxspeed = ch->pcmrates[i - 1]; in hdaa_pcmchannel_setup()
5497 struct hdaa_audio_as *as = devinfo->as; in hdaa_prepare_pcms()
5500 for (i = 0; i < devinfo->ascnt; i++) { in hdaa_prepare_pcms()
5515 devinfo->num_devs = in hdaa_prepare_pcms()
5517 devinfo->devs = malloc(devinfo->num_devs * in hdaa_prepare_pcms()
5519 if (devinfo->devs == NULL) { in hdaa_prepare_pcms()
5520 device_printf(devinfo->dev, in hdaa_prepare_pcms()
5524 for (i = 0; i < devinfo->num_devs; i++) { in hdaa_prepare_pcms()
5525 devinfo->devs[i].index = i; in hdaa_prepare_pcms()
5526 devinfo->devs[i].devinfo = devinfo; in hdaa_prepare_pcms()
5527 devinfo->devs[i].playas = -1; in hdaa_prepare_pcms()
5528 devinfo->devs[i].recas = -1; in hdaa_prepare_pcms()
5529 devinfo->devs[i].digital = 255; in hdaa_prepare_pcms()
5531 for (i = 0; i < devinfo->ascnt; i++) { in hdaa_prepare_pcms()
5534 for (j = 0; j < devinfo->num_devs; j++) { in hdaa_prepare_pcms()
5535 if (devinfo->devs[j].digital != 255 && in hdaa_prepare_pcms()
5536 (!devinfo->devs[j].digital) != in hdaa_prepare_pcms()
5540 if (devinfo->devs[j].recas >= 0) in hdaa_prepare_pcms()
5542 devinfo->devs[j].recas = i; in hdaa_prepare_pcms()
5544 if (devinfo->devs[j].playas >= 0) in hdaa_prepare_pcms()
5546 devinfo->devs[j].playas = i; in hdaa_prepare_pcms()
5548 as[i].pdevinfo = &devinfo->devs[j]; in hdaa_prepare_pcms()
5550 devinfo->chans[as[i].chans[k]].pdevinfo = in hdaa_prepare_pcms()
5551 &devinfo->devs[j]; in hdaa_prepare_pcms()
5553 devinfo->devs[j].digital = as[i].digital; in hdaa_prepare_pcms()
5564 for (i = 0; i < devinfo->num_devs; i++) { in hdaa_create_pcms()
5565 struct hdaa_pcm_devinfo *pdevinfo = &devinfo->devs[i]; in hdaa_create_pcms()
5567 pdevinfo->dev = device_add_child(devinfo->dev, "pcm", DEVICE_UNIT_ANY); in hdaa_create_pcms()
5568 device_set_ivars(pdevinfo->dev, (void *)pdevinfo); in hdaa_create_pcms()
5575 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_dump_ctls()
5593 if (ctl->enable == 0 || in hdaa_dump_ctls()
5594 ctl->widget->enable == 0) in hdaa_dump_ctls()
5596 if (!((pdevinfo->playas >= 0 && in hdaa_dump_ctls()
5597 ctl->widget->bindas == pdevinfo->playas) || in hdaa_dump_ctls()
5598 (pdevinfo->recas >= 0 && in hdaa_dump_ctls()
5599 ctl->widget->bindas == pdevinfo->recas) || in hdaa_dump_ctls()
5600 (ctl->widget->bindas == -2 && pdevinfo->index == 0))) in hdaa_dump_ctls()
5602 if ((ctl->ossmask & (1 << j)) == 0) in hdaa_dump_ctls()
5607 device_printf(pdevinfo->dev, "%s", banner); in hdaa_dump_ctls()
5609 device_printf(pdevinfo->dev, "Unknown Ctl"); in hdaa_dump_ctls()
5614 if (pdevinfo->ossmask & (1 << j)) { in hdaa_dump_ctls()
5616 pdevinfo->minamp[j] / 4, in hdaa_dump_ctls()
5617 pdevinfo->maxamp[j] / 4); in hdaa_dump_ctls()
5622 device_printf(pdevinfo->dev, " +- ctl %2d (nid %3d %s", i, in hdaa_dump_ctls()
5623 ctl->widget->nid, in hdaa_dump_ctls()
5624 (ctl->ndir == HDAA_CTL_IN)?"in ":"out"); in hdaa_dump_ctls()
5625 if (ctl->ndir == HDAA_CTL_IN && ctl->ndir == ctl->dir) in hdaa_dump_ctls()
5626 printf(" %2d): ", ctl->index); in hdaa_dump_ctls()
5629 if (ctl->step > 0) { in hdaa_dump_ctls()
5633 ctl->step + 1, in hdaa_dump_ctls()
5634 ctl->mute?" + mute":""); in hdaa_dump_ctls()
5636 printf("%s\n", ctl->mute?"mute":""); in hdaa_dump_ctls()
5640 device_printf(pdevinfo->dev, "\n"); in hdaa_dump_ctls()
5703 pincap = w->wclass.pin.cap; in hdaa_dump_pin()
5705 device_printf(w->devinfo->dev, " Pin cap: 0x%08x", pincap); in hdaa_dump_pin()
5743 device_printf(w->devinfo->dev, " Pin config: 0x%08x\n", in hdaa_dump_pin()
5744 w->wclass.pin.config); in hdaa_dump_pin()
5745 device_printf(w->devinfo->dev, " Pin control: 0x%08x", w->wclass.pin.ctrl); in hdaa_dump_pin()
5746 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_HPHN_ENABLE) in hdaa_dump_pin()
5748 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_IN_ENABLE) in hdaa_dump_pin()
5750 if (w->wclass.pin.ctrl & HDA_CMD_SET_PIN_WIDGET_CTRL_OUT_ENABLE) in hdaa_dump_pin()
5752 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) { in hdaa_dump_pin()
5753 if ((w->wclass.pin.ctrl & in hdaa_dump_pin()
5756 else if ((w->wclass.pin.ctrl & in hdaa_dump_pin()
5760 if ((w->wclass.pin.ctrl & in hdaa_dump_pin()
5771 device_printf(w->devinfo->dev, "%2d %08x %-2d %-2d " in hdaa_dump_pin_config()
5772 "%-13s %-5s %-7s %-10s %-7s %d%s\n", in hdaa_dump_pin_config()
5773 w->nid, conf, in hdaa_dump_pin_config()
5782 (w->enable == 0)?" DISA":""); in hdaa_dump_pin_config()
5791 device_printf(devinfo->dev, "nid 0x as seq " in hdaa_dump_pin_configs()
5793 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_dump_pin_configs()
5797 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_dump_pin_configs()
5799 hdaa_dump_pin_config(w, w->wclass.pin.config); in hdaa_dump_pin_configs()
5816 ((0 - offset) * (size + 1)) / 4, in hdaa_dump_amp()
5817 ((step - offset) * (size + 1)) / 4); in hdaa_dump_amp()
5827 device_printf(devinfo->dev, "\n"); in hdaa_dump_nodes()
5828 device_printf(devinfo->dev, "Default parameters:\n"); in hdaa_dump_nodes()
5829 hdaa_dump_audio_formats(devinfo->dev, in hdaa_dump_nodes()
5830 devinfo->supp_stream_formats, in hdaa_dump_nodes()
5831 devinfo->supp_pcm_size_rate); in hdaa_dump_nodes()
5832 hdaa_dump_amp(devinfo->dev, devinfo->inamp_cap, " Input"); in hdaa_dump_nodes()
5833 hdaa_dump_amp(devinfo->dev, devinfo->outamp_cap, "Output"); in hdaa_dump_nodes()
5834 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_dump_nodes()
5837 device_printf(devinfo->dev, "Ghost widget nid=%d\n", i); in hdaa_dump_nodes()
5840 device_printf(devinfo->dev, "\n"); in hdaa_dump_nodes()
5841 device_printf(devinfo->dev, " nid: %d%s\n", w->nid, in hdaa_dump_nodes()
5842 (w->enable == 0) ? " [DISABLED]" : ""); in hdaa_dump_nodes()
5843 device_printf(devinfo->dev, " Name: %s\n", w->name); in hdaa_dump_nodes()
5844 device_printf(devinfo->dev, " Widget cap: 0x%08x", in hdaa_dump_nodes()
5845 w->param.widget_cap); in hdaa_dump_nodes()
5846 if (w->param.widget_cap & 0x0ee1) { in hdaa_dump_nodes()
5847 if (HDA_PARAM_AUDIO_WIDGET_CAP_LR_SWAP(w->param.widget_cap)) in hdaa_dump_nodes()
5849 if (HDA_PARAM_AUDIO_WIDGET_CAP_POWER_CTRL(w->param.widget_cap)) in hdaa_dump_nodes()
5851 if (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap)) in hdaa_dump_nodes()
5853 if (HDA_PARAM_AUDIO_WIDGET_CAP_UNSOL_CAP(w->param.widget_cap)) in hdaa_dump_nodes()
5855 if (HDA_PARAM_AUDIO_WIDGET_CAP_PROC_WIDGET(w->param.widget_cap)) in hdaa_dump_nodes()
5857 if (HDA_PARAM_AUDIO_WIDGET_CAP_STRIPE(w->param.widget_cap)) in hdaa_dump_nodes()
5859 1 << (fls(w->wclass.conv.stripecap) - 1)); in hdaa_dump_nodes()
5860 j = HDA_PARAM_AUDIO_WIDGET_CAP_CC(w->param.widget_cap); in hdaa_dump_nodes()
5867 if (w->bindas != -1) { in hdaa_dump_nodes()
5868 device_printf(devinfo->dev, " Association: %d (0x%04x)\n", in hdaa_dump_nodes()
5869 w->bindas, w->bindseqmask); in hdaa_dump_nodes()
5871 if (w->ossmask != 0 || w->ossdev >= 0) { in hdaa_dump_nodes()
5872 device_printf(devinfo->dev, " OSS: %s", in hdaa_dump_nodes()
5873 hdaa_audio_ctl_ossmixer_mask2allname(w->ossmask, buf, sizeof(buf))); in hdaa_dump_nodes()
5874 if (w->ossdev >= 0) in hdaa_dump_nodes()
5875 printf(" (%s)", ossnames[w->ossdev]); in hdaa_dump_nodes()
5878 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_OUTPUT || in hdaa_dump_nodes()
5879 w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) { in hdaa_dump_nodes()
5880 hdaa_dump_audio_formats(devinfo->dev, in hdaa_dump_nodes()
5881 w->param.supp_stream_formats, in hdaa_dump_nodes()
5882 w->param.supp_pcm_size_rate); in hdaa_dump_nodes()
5883 } else if (w->type == in hdaa_dump_nodes()
5884 HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX || w->waspin) in hdaa_dump_nodes()
5886 if (w->param.eapdbtl != HDA_INVALID) in hdaa_dump_nodes()
5887 device_printf(devinfo->dev, " EAPD: 0x%08x\n", in hdaa_dump_nodes()
5888 w->param.eapdbtl); in hdaa_dump_nodes()
5889 if (HDA_PARAM_AUDIO_WIDGET_CAP_OUT_AMP(w->param.widget_cap) && in hdaa_dump_nodes()
5890 w->param.outamp_cap != 0) in hdaa_dump_nodes()
5891 hdaa_dump_amp(devinfo->dev, w->param.outamp_cap, "Output"); in hdaa_dump_nodes()
5892 if (HDA_PARAM_AUDIO_WIDGET_CAP_IN_AMP(w->param.widget_cap) && in hdaa_dump_nodes()
5893 w->param.inamp_cap != 0) in hdaa_dump_nodes()
5894 hdaa_dump_amp(devinfo->dev, w->param.inamp_cap, " Input"); in hdaa_dump_nodes()
5895 if (w->nconns > 0) in hdaa_dump_nodes()
5896 device_printf(devinfo->dev, " Connections: %d\n", w->nconns); in hdaa_dump_nodes()
5897 for (j = 0; j < w->nconns; j++) { in hdaa_dump_nodes()
5898 cw = hdaa_widget_get(devinfo, w->conns[j]); in hdaa_dump_nodes()
5899 device_printf(devinfo->dev, " + %s<- nid=%d [%s]", in hdaa_dump_nodes()
5900 (w->connsenable[j] == 0)?"[DISABLED] ":"", in hdaa_dump_nodes()
5901 w->conns[j], (cw == NULL) ? "GHOST!" : cw->name); in hdaa_dump_nodes()
5904 else if (cw->enable == 0) in hdaa_dump_nodes()
5906 if (w->nconns > 1 && w->selconn == j && w->type != in hdaa_dump_nodes()
5918 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_dump_dst_nid()
5927 if (w == NULL || w->enable == 0) in hdaa_dump_dst_nid()
5931 device_printf(pdevinfo->dev, "%*s", 4, ""); in hdaa_dump_dst_nid()
5933 device_printf(pdevinfo->dev, "%*s + <- ", 4 + (depth - 1) * 7, ""); in hdaa_dump_dst_nid()
5934 printf("nid=%d [%s]", w->nid, w->name); in hdaa_dump_dst_nid()
5937 if (w->ossmask == 0) { in hdaa_dump_dst_nid()
5943 w->ossmask, buf, sizeof(buf))); in hdaa_dump_dst_nid()
5944 if (w->ossdev >= 0) { in hdaa_dump_dst_nid()
5951 for (i = 0; i < w->nconns; i++) { in hdaa_dump_dst_nid()
5952 if (w->connsenable[i] == 0) in hdaa_dump_dst_nid()
5954 cw = hdaa_widget_get(devinfo, w->conns[i]); in hdaa_dump_dst_nid()
5955 if (cw == NULL || cw->enable == 0 || cw->bindas == -1) in hdaa_dump_dst_nid()
5957 hdaa_dump_dst_nid(pdevinfo, w->conns[i], depth + 1); in hdaa_dump_dst_nid()
5965 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_dump_dac()
5971 if (pdevinfo->playas < 0) in hdaa_dump_dac()
5974 device_printf(pdevinfo->dev, "Playback:\n"); in hdaa_dump_dac()
5976 chid = devinfo->as[pdevinfo->playas].chans[0]; in hdaa_dump_dac()
5977 hdaa_dump_audio_formats(pdevinfo->dev, in hdaa_dump_dac()
5978 devinfo->chans[chid].supp_stream_formats, in hdaa_dump_dac()
5979 devinfo->chans[chid].supp_pcm_size_rate); in hdaa_dump_dac()
5980 for (i = 0; i < devinfo->as[pdevinfo->playas].num_chans; i++) { in hdaa_dump_dac()
5981 chid = devinfo->as[pdevinfo->playas].chans[i]; in hdaa_dump_dac()
5982 device_printf(pdevinfo->dev, " DAC:"); in hdaa_dump_dac()
5983 for (nids = devinfo->chans[chid].io; *nids != -1; nids++) in hdaa_dump_dac()
5988 as = &devinfo->as[pdevinfo->playas]; in hdaa_dump_dac()
5990 if (as->pins[i] <= 0) in hdaa_dump_dac()
5992 w = hdaa_widget_get(devinfo, as->pins[i]); in hdaa_dump_dac()
5993 if (w == NULL || w->enable == 0) in hdaa_dump_dac()
5995 device_printf(pdevinfo->dev, "\n"); in hdaa_dump_dac()
5996 hdaa_dump_dst_nid(pdevinfo, as->pins[i], 0); in hdaa_dump_dac()
5998 device_printf(pdevinfo->dev, "\n"); in hdaa_dump_dac()
6004 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_dump_adc()
6009 if (pdevinfo->recas < 0) in hdaa_dump_adc()
6012 device_printf(pdevinfo->dev, "Record:\n"); in hdaa_dump_adc()
6014 chid = devinfo->as[pdevinfo->recas].chans[0]; in hdaa_dump_adc()
6015 hdaa_dump_audio_formats(pdevinfo->dev, in hdaa_dump_adc()
6016 devinfo->chans[chid].supp_stream_formats, in hdaa_dump_adc()
6017 devinfo->chans[chid].supp_pcm_size_rate); in hdaa_dump_adc()
6018 for (i = 0; i < devinfo->as[pdevinfo->recas].num_chans; i++) { in hdaa_dump_adc()
6019 chid = devinfo->as[pdevinfo->recas].chans[i]; in hdaa_dump_adc()
6020 device_printf(pdevinfo->dev, " ADC:"); in hdaa_dump_adc()
6021 for (nids = devinfo->chans[chid].io; *nids != -1; nids++) in hdaa_dump_adc()
6026 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_dump_adc()
6028 if (w == NULL || w->enable == 0) in hdaa_dump_adc()
6030 if (w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_AUDIO_INPUT) in hdaa_dump_adc()
6032 if (w->bindas != pdevinfo->recas) in hdaa_dump_adc()
6034 device_printf(pdevinfo->dev, "\n"); in hdaa_dump_adc()
6037 device_printf(pdevinfo->dev, "\n"); in hdaa_dump_adc()
6043 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_dump_mix()
6048 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_dump_mix()
6050 if (w == NULL || w->enable == 0) in hdaa_dump_mix()
6052 if (w->ossdev != SOUND_MIXER_IMIX) in hdaa_dump_mix()
6054 if (w->bindas != pdevinfo->recas) in hdaa_dump_mix()
6058 device_printf(pdevinfo->dev, "Input Mix:\n"); in hdaa_dump_mix()
6060 device_printf(pdevinfo->dev, "\n"); in hdaa_dump_mix()
6064 device_printf(pdevinfo->dev, "\n"); in hdaa_dump_mix()
6078 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_pindump()
6080 if (w == NULL || w->type != in hdaa_pindump()
6083 hdaa_dump_pin_config(w, w->wclass.pin.config); in hdaa_pindump()
6084 pincap = w->wclass.pin.cap; in hdaa_pindump()
6096 HDA_CMD_SET_PIN_SENSE(0, w->nid, 0)); in hdaa_pindump()
6099 HDA_CMD_GET_PIN_SENSE(0, w->nid)); in hdaa_pindump()
6107 w->nid)); in hdaa_pindump()
6112 (HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL(w->param.widget_cap) && in hdaa_pindump()
6122 HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap), in hdaa_pindump()
6123 HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap), in hdaa_pindump()
6124 HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap), in hdaa_pindump()
6125 HDA_PARAM_GPIO_COUNT_GPI_WAKE(devinfo->gpio_cap), in hdaa_pindump()
6126 HDA_PARAM_GPIO_COUNT_GPI_UNSOL(devinfo->gpio_cap)); in hdaa_pindump()
6140 device_printf(dev, "Applying built-in patches...\n"); in hdaa_configure()
6220 device_printf(dev, "Applying direct built-in patches...\n"); in hdaa_configure()
6235 if (devinfo->quirks != 0) { in hdaa_configure()
6238 if ((devinfo->quirks & in hdaa_configure()
6249 device_printf(dev, "+-----------+\n"); in hdaa_configure()
6251 device_printf(dev, "+-----------+\n"); in hdaa_configure()
6255 device_printf(dev, "+----------------+\n"); in hdaa_configure()
6257 device_printf(dev, "+----------------+\n"); in hdaa_configure()
6262 (ctl->widget != NULL) ? ctl->widget->nid : -1, in hdaa_configure()
6263 (ctl->ndir == HDAA_CTL_IN)?"in ":"out", in hdaa_configure()
6264 (ctl->dir == HDAA_CTL_IN)?"in ":"out", in hdaa_configure()
6265 ctl->index); in hdaa_configure()
6266 if (ctl->childwidget != NULL) in hdaa_configure()
6267 printf(" cnid %3d", ctl->childwidget->nid); in hdaa_configure()
6271 ctl->ossmask); in hdaa_configure()
6274 ctl->mute, ctl->step, ctl->size, ctl->offset, in hdaa_configure()
6275 (ctl->enable == 0) ? " [DISABLED]" : in hdaa_configure()
6276 ((ctl->ossmask == 0) ? " [UNUSED]" : "")); in hdaa_configure()
6293 free(devinfo->ctl, M_HDAA); in hdaa_unconfigure()
6294 devinfo->ctl = NULL; in hdaa_unconfigure()
6295 devinfo->ctlcnt = 0; in hdaa_unconfigure()
6296 free(devinfo->as, M_HDAA); in hdaa_unconfigure()
6297 devinfo->as = NULL; in hdaa_unconfigure()
6298 devinfo->ascnt = 0; in hdaa_unconfigure()
6299 free(devinfo->devs, M_HDAA); in hdaa_unconfigure()
6300 devinfo->devs = NULL; in hdaa_unconfigure()
6301 devinfo->num_devs = 0; in hdaa_unconfigure()
6302 free(devinfo->chans, M_HDAA); in hdaa_unconfigure()
6303 devinfo->chans = NULL; in hdaa_unconfigure()
6304 devinfo->num_chans = 0; in hdaa_unconfigure()
6305 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_unconfigure()
6309 w->enable = 1; in hdaa_unconfigure()
6310 w->selconn = -1; in hdaa_unconfigure()
6311 w->pflags = 0; in hdaa_unconfigure()
6312 w->bindas = -1; in hdaa_unconfigure()
6313 w->bindseqmask = 0; in hdaa_unconfigure()
6314 w->ossdev = -1; in hdaa_unconfigure()
6315 w->ossmask = 0; in hdaa_unconfigure()
6316 for (j = 0; j < w->nconns; j++) in hdaa_unconfigure()
6317 w->connsenable[j] = 1; in hdaa_unconfigure()
6318 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) in hdaa_unconfigure()
6319 w->wclass.pin.config = w->wclass.pin.newconf; in hdaa_unconfigure()
6320 if (w->eld != NULL) { in hdaa_unconfigure()
6321 w->eld_len = 0; in hdaa_unconfigure()
6322 free(w->eld, M_HDAA); in hdaa_unconfigure()
6323 w->eld = NULL; in hdaa_unconfigure()
6331 struct hdaa_devinfo *devinfo = oidp->oid_arg1; in hdaa_sysctl_gpi_state()
6332 device_t dev = devinfo->dev; in hdaa_sysctl_gpi_state()
6339 numgpi = HDA_PARAM_GPIO_COUNT_NUM_GPI(devinfo->gpio_cap); in hdaa_sysctl_gpi_state()
6342 HDA_CMD_GET_GPI_DATA(0, devinfo->nid)); in hdaa_sysctl_gpi_state()
6346 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=%d", in hdaa_sysctl_gpi_state()
6355 struct hdaa_devinfo *devinfo = oidp->oid_arg1; in hdaa_sysctl_gpio_state()
6356 device_t dev = devinfo->dev; in hdaa_sysctl_gpio_state()
6363 numgpio = HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap); in hdaa_sysctl_gpio_state()
6366 HDA_CMD_GET_GPIO_DATA(0, devinfo->nid)); in hdaa_sysctl_gpio_state()
6368 HDA_CMD_GET_GPIO_ENABLE_MASK(0, devinfo->nid)); in hdaa_sysctl_gpio_state()
6370 HDA_CMD_GET_GPIO_DIRECTION(0, devinfo->nid)); in hdaa_sysctl_gpio_state()
6374 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=", in hdaa_sysctl_gpio_state()
6377 n += snprintf(buf + n, sizeof(buf) - n, "disabled"); in hdaa_sysctl_gpio_state()
6380 n += snprintf(buf + n, sizeof(buf) - n, "%sput(%d)", in hdaa_sysctl_gpio_state()
6389 struct hdaa_devinfo *devinfo = oidp->oid_arg1; in hdaa_sysctl_gpio_config()
6394 gpio = devinfo->newgpio; in hdaa_sysctl_gpio_config()
6395 numgpio = HDA_PARAM_GPIO_COUNT_NUM_GPIO(devinfo->gpio_cap); in hdaa_sysctl_gpio_config()
6399 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=%s", in hdaa_sysctl_gpio_config()
6403 if (error != 0 || req->newptr == NULL) in hdaa_sysctl_gpio_config()
6410 devinfo->newgpio = devinfo->gpio = gpio; in hdaa_sysctl_gpio_config()
6419 struct hdaa_devinfo *devinfo = oidp->oid_arg1; in hdaa_sysctl_gpo_state()
6420 device_t dev = devinfo->dev; in hdaa_sysctl_gpo_state()
6427 numgpo = HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap); in hdaa_sysctl_gpo_state()
6430 HDA_CMD_GET_GPO_DATA(0, devinfo->nid)); in hdaa_sysctl_gpo_state()
6434 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=%d", in hdaa_sysctl_gpo_state()
6443 struct hdaa_devinfo *devinfo = oidp->oid_arg1; in hdaa_sysctl_gpo_config()
6448 gpo = devinfo->newgpo; in hdaa_sysctl_gpo_config()
6449 numgpo = HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap); in hdaa_sysctl_gpo_config()
6453 n += snprintf(buf + n, sizeof(buf) - n, "%s%d=%s", in hdaa_sysctl_gpo_config()
6457 if (error != 0 || req->newptr == NULL) in hdaa_sysctl_gpo_config()
6464 devinfo->newgpo = devinfo->gpo = gpo; in hdaa_sysctl_gpo_config()
6477 dev = oidp->oid_arg1; in hdaa_sysctl_reconfig()
6483 if (error != 0 || req->newptr == NULL || val == 0) in hdaa_sysctl_reconfig()
6523 for (i = 0; i < devinfo->num_chans; i++) { in hdaa_suspend()
6524 if (devinfo->chans[i].flags & HDAA_CHN_RUNNING) { in hdaa_suspend()
6525 devinfo->chans[i].flags |= HDAA_CHN_SUSPEND; in hdaa_suspend()
6526 hdaa_channel_stop(&devinfo->chans[i]); in hdaa_suspend()
6532 devinfo->nid); in hdaa_suspend()
6534 hda_command(devinfo->dev, in hdaa_suspend()
6536 devinfo->nid, HDA_CMD_POWER_STATE_D3)); in hdaa_suspend()
6537 callout_stop(&devinfo->poll_jack); in hdaa_suspend()
6539 callout_drain(&devinfo->poll_jack); in hdaa_suspend()
6558 devinfo->nid); in hdaa_resume()
6566 device_printf(dev, "Applying direct built-in patches...\n"); in hdaa_resume()
6575 for (i = 0; i < devinfo->num_devs; i++) { in hdaa_resume()
6576 struct hdaa_pcm_devinfo *pdevinfo = &devinfo->devs[i]; in hdaa_resume()
6578 device_printf(pdevinfo->dev, in hdaa_resume()
6581 if (mixer_reinit(pdevinfo->dev) == -1) in hdaa_resume()
6582 device_printf(pdevinfo->dev, in hdaa_resume()
6589 for (i = 0; i < devinfo->num_chans; i++) { in hdaa_resume()
6590 if (devinfo->chans[i].flags & HDAA_CHN_SUSPEND) { in hdaa_resume()
6591 devinfo->chans[i].flags &= ~HDAA_CHN_SUSPEND; in hdaa_resume()
6592 hdaa_channel_start(&devinfo->chans[i]); in hdaa_resume()
6611 (int)(strlen(pdesc) - 10), pdesc); in hdaa_probe()
6622 devinfo->dev = dev; in hdaa_attach()
6623 devinfo->lock = HDAC_GET_MTX(device_get_parent(dev), dev); in hdaa_attach()
6624 devinfo->nid = nid; in hdaa_attach()
6625 devinfo->newquirks = -1; in hdaa_attach()
6626 devinfo->newgpio = -1; in hdaa_attach()
6627 devinfo->newgpo = -1; in hdaa_attach()
6628 callout_init(&devinfo->poll_jack, 1); in hdaa_attach()
6629 devinfo->poll_ival = hz; in hdaa_attach()
6636 devinfo->nodecnt = HDA_PARAM_SUB_NODE_COUNT_TOTAL(res); in hdaa_attach()
6637 devinfo->startnode = HDA_PARAM_SUB_NODE_COUNT_START(res); in hdaa_attach()
6638 devinfo->endnode = devinfo->startnode + devinfo->nodecnt; in hdaa_attach()
6646 "Audio Function Group at nid=%d: %d subnodes %d-%d\n", in hdaa_attach()
6647 nid, devinfo->nodecnt, in hdaa_attach()
6648 devinfo->startnode, devinfo->endnode - 1); in hdaa_attach()
6651 if (devinfo->nodecnt > 0) in hdaa_attach()
6652 devinfo->widget = malloc(sizeof(*(devinfo->widget)) * in hdaa_attach()
6653 devinfo->nodecnt, M_HDAA, M_WAITOK | M_ZERO); in hdaa_attach()
6655 devinfo->widget = NULL; in hdaa_attach()
6676 &devinfo->newquirks, 0, hdaa_sysctl_quirks, "A", in hdaa_attach()
6705 &devinfo->init_clear, 1,"Clear initial pin widget configuration"); in hdaa_attach()
6721 devinfo->poll_ival = 0; in hdaa_detach()
6722 callout_stop(&devinfo->poll_jack); in hdaa_detach()
6724 callout_drain(&devinfo->poll_jack); in hdaa_detach()
6726 free(devinfo->widget, M_HDAA); in hdaa_detach()
6741 if (pdevinfo->playas >= 0) { in hdaa_print_child()
6742 as = &devinfo->as[pdevinfo->playas]; in hdaa_print_child()
6744 if (as->pins[i] <= 0) in hdaa_print_child()
6746 retval += printf("%s%d", first ? "" : ",", as->pins[i]); in hdaa_print_child()
6750 if (pdevinfo->recas >= 0) { in hdaa_print_child()
6751 if (pdevinfo->playas >= 0) { in hdaa_print_child()
6755 as = &devinfo->as[pdevinfo->recas]; in hdaa_print_child()
6757 if (as->pins[i] <= 0) in hdaa_print_child()
6759 retval += printf("%s%d", first ? "" : ",", as->pins[i]); in hdaa_print_child()
6778 if (pdevinfo->playas >= 0) { in hdaa_child_location()
6779 as = &devinfo->as[pdevinfo->playas]; in hdaa_child_location()
6781 if (as->pins[i] <= 0) in hdaa_child_location()
6783 sbuf_printf(sb, "%s%d", first ? "" : ",", as->pins[i]); in hdaa_child_location()
6787 if (pdevinfo->recas >= 0) { in hdaa_child_location()
6788 as = &devinfo->as[pdevinfo->recas]; in hdaa_child_location()
6790 if (as->pins[i] <= 0) in hdaa_child_location()
6792 sbuf_printf(sb, "%s%d", first ? "" : ",", as->pins[i]); in hdaa_child_location()
6806 for (i = 0; i < devinfo->num_chans; i++) { in hdaa_stream_intr()
6807 ch = &devinfo->chans[i]; in hdaa_stream_intr()
6808 if (!(ch->flags & HDAA_CHN_RUNNING)) in hdaa_stream_intr()
6810 if (ch->dir == ((dir == 1) ? PCMDIR_PLAY : PCMDIR_REC) && in hdaa_stream_intr()
6811 ch->sid == stream) { in hdaa_stream_intr()
6813 chn_intr(ch->c); in hdaa_stream_intr()
6830 for (i = devinfo->startnode; i < devinfo->endnode; i++) { in hdaa_unsol_intr()
6832 if (w == NULL || w->enable == 0 || w->type != in hdaa_unsol_intr()
6835 if (w->unsol != tag) in hdaa_unsol_intr()
6837 if (HDA_PARAM_PIN_CAP_DP(w->wclass.pin.cap) || in hdaa_unsol_intr()
6838 HDA_PARAM_PIN_CAP_HDMI(w->wclass.pin.cap)) in hdaa_unsol_intr()
6880 as = &devinfo->as[asid]; in hdaa_chan_formula()
6881 c = devinfo->chans[as->chans[0]].channels; in hdaa_chan_formula()
6885 if (as->hpredir < 0) in hdaa_chan_formula()
6889 } else if (as->pinset == 0x0003) in hdaa_chan_formula()
6891 else if (as->pinset == 0x0005 || as->pinset == 0x0011) in hdaa_chan_formula()
6893 else if (as->pinset == 0x0007 || as->pinset == 0x0013) in hdaa_chan_formula()
6895 else if (as->pinset == 0x0017) in hdaa_chan_formula()
6899 if (as->hpredir >= 0) in hdaa_chan_formula()
6908 int i, t = -1, t1; in hdaa_chan_type()
6910 as = &devinfo->as[asid]; in hdaa_chan_type()
6912 w = hdaa_widget_get(devinfo, as->pins[i]); in hdaa_chan_type()
6913 if (w == NULL || w->enable == 0 || w->type != in hdaa_chan_type()
6916 t1 = HDA_CONFIG_DEFAULTCONF_DEVICE(w->wclass.pin.config); in hdaa_chan_type()
6917 if (t == -1) in hdaa_chan_type()
6920 t = -2; in hdaa_chan_type()
6930 struct hdaa_audio_as *as = (struct hdaa_audio_as *)oidp->oid_arg1; in hdaa_sysctl_32bit()
6931 struct hdaa_pcm_devinfo *pdevinfo = as->pdevinfo; in hdaa_sysctl_32bit()
6932 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_sysctl_32bit()
6937 ch = &devinfo->chans[as->chans[0]]; in hdaa_sysctl_32bit()
6938 val = (ch->bit32 == 4) ? 32 : ((ch->bit32 == 3) ? 24 : in hdaa_sysctl_32bit()
6939 ((ch->bit32 == 2) ? 20 : 0)); in hdaa_sysctl_32bit()
6941 if (error != 0 || req->newptr == NULL) in hdaa_sysctl_32bit()
6943 pcmcap = ch->supp_pcm_size_rate; in hdaa_sysctl_32bit()
6945 ch->bit32 = 4; in hdaa_sysctl_32bit()
6947 ch->bit32 = 3; in hdaa_sysctl_32bit()
6949 ch->bit32 = 2; in hdaa_sysctl_32bit()
6952 for (i = 1; i < as->num_chans; i++) in hdaa_sysctl_32bit()
6953 devinfo->chans[as->chans[i]].bit32 = ch->bit32; in hdaa_sysctl_32bit()
6962 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_pcm_probe()
6967 if (pdevinfo->playas >= 0) in hdaa_pcm_probe()
6968 loc1 = devinfo->as[pdevinfo->playas].location; in hdaa_pcm_probe()
6970 loc1 = devinfo->as[pdevinfo->recas].location; in hdaa_pcm_probe()
6971 if (pdevinfo->recas >= 0) in hdaa_pcm_probe()
6972 loc2 = devinfo->as[pdevinfo->recas].location; in hdaa_pcm_probe()
6976 loc1 = -2; in hdaa_pcm_probe()
6978 loc1 = -2; in hdaa_pcm_probe()
6981 t1 = t2 = -1; in hdaa_pcm_probe()
6982 if (pdevinfo->playas >= 0) { in hdaa_pcm_probe()
6983 hdaa_chan_formula(devinfo, pdevinfo->playas, in hdaa_pcm_probe()
6985 t1 = hdaa_chan_type(devinfo, pdevinfo->playas); in hdaa_pcm_probe()
6987 if (pdevinfo->recas >= 0) { in hdaa_pcm_probe()
6988 hdaa_chan_formula(devinfo, pdevinfo->recas, in hdaa_pcm_probe()
6990 t2 = hdaa_chan_type(devinfo, pdevinfo->recas); in hdaa_pcm_probe()
6993 if (chans1[0] == 0 && pdevinfo->playas >= 0) in hdaa_pcm_probe()
6995 else if (chans2[0] == 0 && pdevinfo->recas >= 0) in hdaa_pcm_probe()
7000 if (t1 == -1) in hdaa_pcm_probe()
7002 else if (t2 == -1) in hdaa_pcm_probe()
7005 t1 = -2; in hdaa_pcm_probe()
7006 if (pdevinfo->digital) in hdaa_pcm_probe()
7007 t1 = -2; in hdaa_pcm_probe()
7010 (int)(strlen(pdesc) - 21), pdesc, in hdaa_pcm_probe()
7012 (pdevinfo->digital == 0x7)?"HDMI/DP": in hdaa_pcm_probe()
7013 ((pdevinfo->digital == 0x5)?"DisplayPort": in hdaa_pcm_probe()
7014 ((pdevinfo->digital == 0x3)?"HDMI": in hdaa_pcm_probe()
7015 ((pdevinfo->digital)?"Digital":"Analog"))), in hdaa_pcm_probe()
7027 struct hdaa_devinfo *devinfo = pdevinfo->devinfo; in hdaa_pcm_attach()
7033 pdevinfo->chan_size = pcm_getbuffersize(dev, in hdaa_pcm_attach()
7045 hdaa_dump_ctls(pdevinfo, "Line-in Volume", SOUND_MASK_LINE); in hdaa_pcm_attach()
7058 pdevinfo->chan_blkcnt = pdevinfo->chan_size / i; in hdaa_pcm_attach()
7060 while (pdevinfo->chan_blkcnt >> i) in hdaa_pcm_attach()
7062 pdevinfo->chan_blkcnt = 1 << (i - 1); in hdaa_pcm_attach()
7063 if (pdevinfo->chan_blkcnt < HDA_BDL_MIN) in hdaa_pcm_attach()
7064 pdevinfo->chan_blkcnt = HDA_BDL_MIN; in hdaa_pcm_attach()
7065 else if (pdevinfo->chan_blkcnt > HDA_BDL_MAX) in hdaa_pcm_attach()
7066 pdevinfo->chan_blkcnt = HDA_BDL_MAX; in hdaa_pcm_attach()
7068 pdevinfo->chan_blkcnt = HDA_BDL_DEFAULT; in hdaa_pcm_attach()
7087 pdevinfo->registered++; in hdaa_pcm_attach()
7090 if (pdevinfo->playas >= 0) { in hdaa_pcm_attach()
7091 as = &devinfo->as[pdevinfo->playas]; in hdaa_pcm_attach()
7092 for (i = 0; i < as->num_chans; i++) in hdaa_pcm_attach()
7094 &devinfo->chans[as->chans[i]]); in hdaa_pcm_attach()
7095 SYSCTL_ADD_PROC(&d->play_sysctl_ctx, in hdaa_pcm_attach()
7096 SYSCTL_CHILDREN(d->play_sysctl_tree), OID_AUTO, in hdaa_pcm_attach()
7101 if (pdevinfo->recas >= 0) { in hdaa_pcm_attach()
7102 as = &devinfo->as[pdevinfo->recas]; in hdaa_pcm_attach()
7103 for (i = 0; i < as->num_chans; i++) in hdaa_pcm_attach()
7105 &devinfo->chans[as->chans[i]]); in hdaa_pcm_attach()
7106 SYSCTL_ADD_PROC(&d->rec_sysctl_ctx, in hdaa_pcm_attach()
7107 SYSCTL_CHILDREN(d->rec_sysctl_tree), OID_AUTO, in hdaa_pcm_attach()
7111 pdevinfo->autorecsrc = 2; in hdaa_pcm_attach()
7113 "rec.autosrc", &pdevinfo->autorecsrc); in hdaa_pcm_attach()
7114 SYSCTL_ADD_INT(&d->rec_sysctl_ctx, in hdaa_pcm_attach()
7115 SYSCTL_CHILDREN(d->rec_sysctl_tree), OID_AUTO, in hdaa_pcm_attach()
7117 &pdevinfo->autorecsrc, 0, in hdaa_pcm_attach()
7121 if (pdevinfo->mixer != NULL) { in hdaa_pcm_attach()
7124 if (pdevinfo->playas >= 0) { in hdaa_pcm_attach()
7125 as = &devinfo->as[pdevinfo->playas]; in hdaa_pcm_attach()
7128 if (pdevinfo->recas >= 0) { in hdaa_pcm_attach()
7129 as = &devinfo->as[pdevinfo->recas]; in hdaa_pcm_attach()
7149 if (pdevinfo->registered > 0) { in hdaa_pcm_detach()