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