Lines Matching +full:event +full:- +full:touch +full:- +full:alt
1 // SPDX-License-Identifier: GPL-2.0-or-later
32 * snd_hda_gen_spec_init - initialize hda_gen_spec struct
39 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); in snd_hda_gen_spec_init()
40 snd_array_init(&spec->paths, sizeof(struct nid_path), 8); in snd_hda_gen_spec_init()
41 snd_array_init(&spec->loopback_list, sizeof(struct hda_amp_list), 8); in snd_hda_gen_spec_init()
42 mutex_init(&spec->pcm_mutex); in snd_hda_gen_spec_init()
48 * snd_hda_gen_add_kctl - Add a new kctl_new struct from the template
62 struct snd_kcontrol_new *knew = snd_array_new(&spec->kctls); in snd_hda_gen_add_kctl()
67 knew->name = kstrdup(name, GFP_KERNEL); in snd_hda_gen_add_kctl()
68 else if (knew->name) in snd_hda_gen_add_kctl()
69 knew->name = kstrdup(knew->name, GFP_KERNEL); in snd_hda_gen_add_kctl()
70 if (!knew->name) in snd_hda_gen_add_kctl()
78 if (spec->kctls.list) { in free_kctls()
79 struct snd_kcontrol_new *kctl = spec->kctls.list; in free_kctls()
81 for (i = 0; i < spec->kctls.used; i++) in free_kctls()
84 snd_array_free(&spec->kctls); in free_kctls()
92 snd_array_free(&spec->paths); in snd_hda_gen_spec_free()
93 snd_array_free(&spec->loopback_list); in snd_hda_gen_spec_free()
101 struct hda_gen_spec *spec = codec->spec; in parse_user_hints()
106 codec->no_jack_detect = !val; in parse_user_hints()
109 codec->inv_jack_detect = !!val; in parse_user_hints()
112 codec->no_trigger_sense = !val; in parse_user_hints()
115 codec->inv_eapd = !!val; in parse_user_hints()
118 codec->pcm_format_first = !!val; in parse_user_hints()
121 codec->no_sticky_stream = !val; in parse_user_hints()
124 codec->spdif_status_reset = !!val; in parse_user_hints()
127 codec->pin_amp_workaround = !!val; in parse_user_hints()
130 codec->single_adc_amp = !!val; in parse_user_hints()
133 codec->power_save_node = !!val; in parse_user_hints()
137 spec->suppress_auto_mute = !val; in parse_user_hints()
140 spec->suppress_auto_mic = !val; in parse_user_hints()
143 spec->line_in_auto_switch = !!val; in parse_user_hints()
146 spec->auto_mute_via_amp = !!val; in parse_user_hints()
149 spec->need_dac_fix = !!val; in parse_user_hints()
152 spec->no_primary_hp = !val; in parse_user_hints()
155 spec->no_multi_io = !val; in parse_user_hints()
158 spec->multi_cap_vol = !!val; in parse_user_hints()
161 spec->inv_dmic_split = !!val; in parse_user_hints()
164 spec->indep_hp = !!val; in parse_user_hints()
167 spec->add_stereo_mix_input = !!val; in parse_user_hints()
171 spec->add_jack_modes = !!val; in parse_user_hints()
174 spec->add_jack_modes = !!val; in parse_user_hints()
177 spec->add_jack_modes = !!val; in parse_user_hints()
180 spec->power_down_unused = !!val; in parse_user_hints()
183 spec->hp_mic = !!val; in parse_user_hints()
186 spec->suppress_hp_mic_detect = !val; in parse_user_hints()
189 spec->suppress_vmaster = !val; in parse_user_hints()
192 spec->mixer_nid = val; in parse_user_hints()
234 /* return the position of NID in the list, or -1 if not found */
241 return -1; in find_idx_in_nid_list()
247 return find_idx_in_nid_list(nid, path->path, path->depth) >= 0; in is_nid_contained()
254 struct hda_gen_spec *spec = codec->spec; in get_nid_path()
258 snd_array_for_each(&spec->paths, i, path) { in get_nid_path()
259 if (path->depth <= 0) in get_nid_path()
261 if ((!from_nid || path->path[0] == from_nid) && in get_nid_path()
262 (!to_nid || path->path[path->depth - 1] == to_nid)) { in get_nid_path()
273 * snd_hda_get_path_idx - get the index number corresponding to the path
283 struct hda_gen_spec *spec = codec->spec; in snd_hda_get_path_idx()
284 struct nid_path *array = spec->paths.list; in snd_hda_get_path_idx()
287 if (!spec->paths.used) in snd_hda_get_path_idx()
289 idx = path - array; in snd_hda_get_path_idx()
290 if (idx < 0 || idx >= spec->paths.used) in snd_hda_get_path_idx()
297 * snd_hda_get_path_from_idx - get the path instance corresponding to the
304 struct hda_gen_spec *spec = codec->spec; in snd_hda_get_path_from_idx()
306 if (idx <= 0 || idx > spec->paths.used) in snd_hda_get_path_from_idx()
308 return snd_array_elem(&spec->paths, idx - 1); in snd_hda_get_path_from_idx()
315 struct hda_gen_spec *spec = codec->spec; in is_dac_already_used()
319 snd_array_for_each(&spec->paths, i, path) { in is_dac_already_used()
320 if (path->path[0] == nid) in is_dac_already_used()
341 struct hda_gen_spec *spec = codec->spec; in is_ctl_used()
346 snd_array_for_each(&spec->paths, i, path) { in is_ctl_used()
347 if ((path->ctls[type] & AMP_VAL_COMPARE_MASK) == val) in is_ctl_used()
369 for (i = 0; i < path->depth; i++) in print_nid_path()
370 pos += scnprintf(pos, sizeof(buf) - (pos - buf), "%s%02x", in print_nid_path()
372 path->path[i]); in print_nid_path()
374 codec_dbg(codec, "%s path: depth=%d '%s'\n", pfx, path->depth, buf); in print_nid_path()
388 else if (to_nid == (hda_nid_t)(-anchor_nid)) in __parse_nid_path()
421 path->path[path->depth] = conn[i]; in __parse_nid_path()
422 path->idx[path->depth + 1] = i; in __parse_nid_path()
424 path->multi[path->depth + 1] = 1; in __parse_nid_path()
425 path->depth++; in __parse_nid_path()
430 * snd_hda_parse_nid_path - parse the widget path from the given nid to
453 path->path[path->depth] = to_nid; in snd_hda_parse_nid_path()
454 path->depth++; in snd_hda_parse_nid_path()
461 * snd_hda_add_new_path - parse the path between the given NIDs and
474 struct hda_gen_spec *spec = codec->spec; in snd_hda_add_new_path()
485 path = snd_array_new(&spec->paths); in snd_hda_add_new_path()
492 spec->paths.used--; in snd_hda_add_new_path()
509 struct hda_gen_spec *spec = codec->spec; in get_preferred_dac()
510 const hda_nid_t *list = spec->preferred_dacs; in get_preferred_dac()
524 struct hda_gen_spec *spec = codec->spec; in look_for_dac()
528 for (i = 0; i < spec->num_all_dacs; i++) { in look_for_dac()
529 hda_nid_t nid = spec->all_dacs[i]; in look_for_dac()
564 for (i = path->depth - 1; i >= 0; i--) { in look_for_out_mute_nid()
565 if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) in look_for_out_mute_nid()
566 return path->path[i]; in look_for_out_mute_nid()
567 if (i != path->depth - 1 && i != 0 && in look_for_out_mute_nid()
568 nid_has_mute(codec, path->path[i], HDA_INPUT)) in look_for_out_mute_nid()
569 return path->path[i]; in look_for_out_mute_nid()
578 struct hda_gen_spec *spec = codec->spec; in look_for_out_vol_nid()
581 for (i = path->depth - 1; i >= 0; i--) { in look_for_out_vol_nid()
582 hda_nid_t nid = path->path[i]; in look_for_out_vol_nid()
583 if ((spec->out_vol_mask >> nid) & 1) in look_for_out_vol_nid()
595 /* can have the amp-in capability? */
598 hda_nid_t nid = path->path[idx]; in has_amp_in()
609 /* can have the amp-out capability? */
612 hda_nid_t nid = path->path[idx]; in has_amp_out()
627 struct hda_gen_spec *spec = codec->spec; in is_active_nid()
632 if (nid == codec->core.afg) in is_active_nid()
635 snd_array_for_each(&spec->paths, n, path) { in is_active_nid()
636 if (!path->active) in is_active_nid()
638 if (codec->power_save_node) { in is_active_nid()
639 if (!path->stream_enabled) in is_active_nid()
642 if (!(path->pin_enabled || path->pin_fixed) && in is_active_nid()
646 for (i = 0; i < path->depth; i++) { in is_active_nid()
647 if (path->path[i] == nid) { in is_active_nid()
648 if (dir == HDA_OUTPUT || idx == -1 || in is_active_nid()
649 path->idx[i] == idx) in is_active_nid()
660 is_active_nid(codec, nid, HDA_OUTPUT, -1)
680 /* is this a stereo widget or a stereo-to-mono mix? */
722 * if the given amp is controlled by mixers, don't touch it
771 hda_nid_t nid = path->path[i]; in activate_amp_out()
779 struct hda_gen_spec *spec = codec->spec; in activate_amp_in()
783 hda_nid_t nid = path->path[i]; in activate_amp_in()
790 (type == AC_WID_AUD_IN && codec->single_adc_amp)) { in activate_amp_in()
794 idx = path->idx[i]; in activate_amp_in()
800 * when aa-mixer is available, we need to enable the path as well in activate_amp_in()
804 if (conn[n] != spec->mixer_merge_nid) in activate_amp_in()
824 for (i = 0; i < path->depth; i++) { in path_power_update()
825 nid = path->path[i]; in path_power_update()
828 if (nid == codec->core.afg) in path_power_update()
848 snd_hdac_regmap_sync_node(&codec->core, nid); in path_power_update()
865 * snd_hda_activate_path - activate or deactivate the given path
871 * If @add_aamix is set, enable the input from aa-mix NID as well (if any).
876 struct hda_gen_spec *spec = codec->spec; in snd_hda_activate_path()
879 path->active = enable; in snd_hda_activate_path()
882 if (enable && (spec->power_down_unused || codec->power_save_node)) in snd_hda_activate_path()
883 path_power_update(codec, path, codec->power_save_node); in snd_hda_activate_path()
885 for (i = path->depth - 1; i >= 0; i--) { in snd_hda_activate_path()
886 hda_nid_t nid = path->path[i]; in snd_hda_activate_path()
888 if (enable && path->multi[i]) in snd_hda_activate_path()
891 path->idx[i]); in snd_hda_activate_path()
903 struct hda_gen_spec *spec = codec->spec; in path_power_down_sync()
905 if (!(spec->power_down_unused || codec->power_save_node) || path->active) in path_power_down_sync()
913 struct hda_gen_spec *spec = codec->spec; in set_pin_eapd()
914 if (spec->own_eapd_ctl || in set_pin_eapd()
917 if (spec->keep_eapd_on && !enable) in set_pin_eapd()
919 if (codec->inv_eapd) in set_pin_eapd()
926 /* re-initialize the path specified by the given path index */
931 snd_hda_activate_path(codec, path, path->active, false); in resume_path_from_idx()
981 knew->index = cidx; in add_control()
983 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in add_control()
984 knew->private_value = val; in add_control()
995 return -ENOMEM; in add_control_with_pfx()
1014 val = path->ctls[NID_PATH_VOL_CTL]; in add_vol_ctl()
1018 return __add_pb_vol_ctrl(codec->spec, HDA_CTL_WIDGET_VOL, pfx, cidx, val); in add_vol_ctl()
1021 /* return the channel bits suitable for the given path->ctls[] */
1027 hda_nid_t nid = get_amp_nid_(path->ctls[type]); in get_default_ch_nums()
1041 /* create a mute-switch for the given mixer widget;
1042 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
1052 val = path->ctls[NID_PATH_MUTE_CTL]; in add_sw_ctl()
1064 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); in add_sw_ctl()
1079 struct hda_gen_spec *spec = codec->spec; in sync_auto_mute_bits()
1081 if (spec->auto_mute_via_amp) { in sync_auto_mute_bits()
1083 bool enabled = !((spec->mute_bits >> nid) & 1); in sync_auto_mute_bits()
1084 ucontrol->value.integer.value[0] &= enabled; in sync_auto_mute_bits()
1085 ucontrol->value.integer.value[1] &= enabled; in sync_auto_mute_bits()
1109 mutex_lock(&codec->control_mutex); in hda_gen_bind_mute_get()
1110 pval = kcontrol->private_value; in hda_gen_bind_mute_get()
1111 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ in hda_gen_bind_mute_get()
1113 kcontrol->private_value = pval; in hda_gen_bind_mute_get()
1114 mutex_unlock(&codec->control_mutex); in hda_gen_bind_mute_get()
1127 mutex_lock(&codec->control_mutex); in hda_gen_bind_mute_put()
1128 pval = kcontrol->private_value; in hda_gen_bind_mute_put()
1131 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | in hda_gen_bind_mute_put()
1138 kcontrol->private_value = pval; in hda_gen_bind_mute_put()
1139 mutex_unlock(&codec->control_mutex); in hda_gen_bind_mute_put()
1147 return path && path->ctls[ctl_type]; in path_has_mixer()
1158 struct hda_gen_spec *spec = codec->spec; in get_line_out_pfx()
1159 struct auto_pin_cfg *cfg = &spec->autocfg; in get_line_out_pfx()
1162 if (cfg->line_outs == 1 && !spec->multi_ios && in get_line_out_pfx()
1163 !codec->force_pin_prefix && in get_line_out_pfx()
1164 !cfg->hp_outs && !cfg->speaker_outs) in get_line_out_pfx()
1165 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1170 if (spec->multiout.num_dacs == 1 && !spec->mixer_nid && in get_line_out_pfx()
1171 !codec->force_pin_prefix && in get_line_out_pfx()
1172 !spec->multiout.hp_out_nid[0] && !spec->multiout.extra_out_nid[0]) in get_line_out_pfx()
1173 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1175 /* multi-io channels */ in get_line_out_pfx()
1176 if (ch >= cfg->line_outs) in get_line_out_pfx()
1179 switch (cfg->line_out_type) { in get_line_out_pfx()
1184 if (!ch && cfg->hp_outs && in get_line_out_pfx()
1185 !path_has_mixer(codec, spec->hp_paths[0], ctl_type)) in get_line_out_pfx()
1187 if (cfg->line_outs == 1) in get_line_out_pfx()
1189 if (cfg->line_outs == 2) in get_line_out_pfx()
1196 if (!ch && cfg->speaker_outs && in get_line_out_pfx()
1197 !path_has_mixer(codec, spec->speaker_paths[0], ctl_type)) in get_line_out_pfx()
1199 /* for multi-io case, only the primary out */ in get_line_out_pfx()
1200 if (ch && spec->multi_ios) in get_line_out_pfx()
1207 if (!ch && cfg->speaker_outs && cfg->hp_outs) { in get_line_out_pfx()
1208 bool hp_lo_shared = !path_has_mixer(codec, spec->hp_paths[0], ctl_type); in get_line_out_pfx()
1209 bool spk_lo_shared = !path_has_mixer(codec, spec->speaker_paths[0], ctl_type); in get_line_out_pfx()
1211 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1220 if (cfg->line_outs == 1 && !spec->multi_ios) in get_line_out_pfx()
1241 /* No possible multi-ios */
1268 struct hda_gen_spec *spec = codec->spec; in assign_out_path_ctls()
1276 if (path->ctls[NID_PATH_VOL_CTL] || in assign_out_path_ctls()
1277 path->ctls[NID_PATH_MUTE_CTL]) in assign_out_path_ctls()
1283 if (spec->dac_min_mute) in assign_out_path_ctls()
1288 path->ctls[NID_PATH_VOL_CTL] = val; in assign_out_path_ctls()
1302 path->ctls[NID_PATH_MUTE_CTL] = val; in assign_out_path_ctls()
1331 struct hda_gen_spec *spec = codec->spec; in get_primary_out()
1332 struct auto_pin_cfg *cfg = &spec->autocfg; in get_primary_out()
1334 if (cfg->line_outs > idx) in get_primary_out()
1335 return spec->private_dac_nids[idx]; in get_primary_out()
1336 idx -= cfg->line_outs; in get_primary_out()
1337 if (spec->multi_ios > idx) in get_primary_out()
1338 return spec->multi_io[idx].dac; in get_primary_out()
1355 struct hda_gen_spec *spec = codec->spec; in try_assign_dacs()
1367 if (!spec->obey_preferred_dacs) { in try_assign_dacs()
1378 badness += bad->shared_primary; in try_assign_dacs()
1379 } else if (spec->obey_preferred_dacs) { in try_assign_dacs()
1407 badness += bad->shared_primary; in try_assign_dacs()
1409 badness += bad->shared_surr; in try_assign_dacs()
1411 badness += bad->shared_clfe; in try_assign_dacs()
1412 } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { in try_assign_dacs()
1413 dac = spec->private_dac_nids[0]; in try_assign_dacs()
1414 badness += bad->shared_surr_main; in try_assign_dacs()
1416 badness += bad->no_primary_dac; in try_assign_dacs()
1418 badness += bad->no_dac; in try_assign_dacs()
1422 path = snd_hda_add_new_path(codec, dac, pin, -spec->mixer_nid); in try_assign_dacs()
1423 if (!path && !i && spec->mixer_nid) { in try_assign_dacs()
1429 badness += bad->no_dac; in try_assign_dacs()
1432 path->active = true; in try_assign_dacs()
1444 struct hda_gen_spec *spec = codec->spec; in get_dac_if_single()
1448 for (i = 0; i < spec->num_all_dacs; i++) { in get_dac_if_single()
1449 hda_nid_t nid = spec->all_dacs[i]; in get_dac_if_single()
1461 /* check whether the given pin can be a multi-io pin */
1478 /* count the number of input pins that are capable to be multi-io */
1481 struct hda_gen_spec *spec = codec->spec; in count_multiio_pins()
1482 struct auto_pin_cfg *cfg = &spec->autocfg; in count_multiio_pins()
1488 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { in count_multiio_pins()
1489 for (i = 0; i < cfg->num_inputs; i++) { in count_multiio_pins()
1490 if (cfg->inputs[i].type != type) in count_multiio_pins()
1493 cfg->inputs[i].pin)) in count_multiio_pins()
1501 * multi-io helper
1504 * zero if any pins are filled, non-zero if nothing found.
1512 struct hda_gen_spec *spec = codec->spec; in fill_multi_ios()
1513 struct auto_pin_cfg *cfg = &spec->autocfg; in fill_multi_ios()
1520 old_pins = spec->multi_ios; in fill_multi_ios()
1528 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { in fill_multi_ios()
1529 for (i = 0; i < cfg->num_inputs; i++) { in fill_multi_ios()
1530 hda_nid_t nid = cfg->inputs[i].pin; in fill_multi_ios()
1533 if (cfg->inputs[i].type != type) in fill_multi_ios()
1537 for (j = 0; j < spec->multi_ios; j++) { in fill_multi_ios()
1538 if (nid == spec->multi_io[j].pin) in fill_multi_ios()
1541 if (j < spec->multi_ios) in fill_multi_ios()
1553 -spec->mixer_nid); in fill_multi_ios()
1559 spec->multi_io[spec->multi_ios].pin = nid; in fill_multi_ios()
1560 spec->multi_io[spec->multi_ios].dac = dac; in fill_multi_ios()
1561 spec->out_paths[cfg->line_outs + spec->multi_ios] = in fill_multi_ios()
1563 spec->multi_ios++; in fill_multi_ios()
1564 if (spec->multi_ios >= 2) in fill_multi_ios()
1571 if (old_pins == spec->multi_ios) { in fill_multi_ios()
1577 if (!hardwired && spec->multi_ios < 2) { in fill_multi_ios()
1579 spec->paths.used -= spec->multi_ios - old_pins; in fill_multi_ios()
1580 spec->multi_ios = old_pins; in fill_multi_ios()
1585 for (i = old_pins; i < spec->multi_ios; i++) { in fill_multi_ios()
1586 path = snd_hda_get_path_from_idx(codec, spec->out_paths[cfg->line_outs + i]); in fill_multi_ios()
1597 struct hda_gen_spec *spec = codec->spec; in map_singles()
1609 -spec->mixer_nid); in map_singles()
1610 if (!path && !i && spec->mixer_nid) in map_singles()
1616 path->active = true; in map_singles()
1625 return spec->aamix_out_paths[0] || spec->aamix_out_paths[1] || in has_aamix_out_paths()
1626 spec->aamix_out_paths[2]; in has_aamix_out_paths()
1632 struct hda_gen_spec *spec = codec->spec; in check_aamix_out_path()
1637 if (!path || !path->depth || in check_aamix_out_path()
1638 is_nid_contained(path, spec->mixer_nid)) in check_aamix_out_path()
1640 path_dac = path->path[0]; in check_aamix_out_path()
1641 dac = spec->private_dac_nids[0]; in check_aamix_out_path()
1642 pin = path->path[path->depth - 1]; in check_aamix_out_path()
1643 path = snd_hda_add_new_path(codec, dac, pin, spec->mixer_nid); in check_aamix_out_path()
1647 else if (spec->multiout.hp_out_nid[0]) in check_aamix_out_path()
1648 dac = spec->multiout.hp_out_nid[0]; in check_aamix_out_path()
1649 else if (spec->multiout.extra_out_nid[0]) in check_aamix_out_path()
1650 dac = spec->multiout.extra_out_nid[0]; in check_aamix_out_path()
1655 spec->mixer_nid); in check_aamix_out_path()
1659 /* print_nid_path(codec, "output-aamix", path); */ in check_aamix_out_path()
1660 path->active = false; /* unused as default */ in check_aamix_out_path()
1661 path->pin_fixed = true; /* static route */ in check_aamix_out_path()
1668 struct hda_gen_spec *spec = codec->spec; in indep_hp_possible()
1669 struct auto_pin_cfg *cfg = &spec->autocfg; in indep_hp_possible()
1673 if (cfg->line_out_type == AUTO_PIN_HP_OUT) in indep_hp_possible()
1674 idx = spec->out_paths[0]; in indep_hp_possible()
1676 idx = spec->hp_paths[0]; in indep_hp_possible()
1682 if (!spec->mixer_nid || !is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1686 for (i = 0; i < cfg->line_outs; i++) { in indep_hp_possible()
1687 if (spec->out_paths[i] == idx) in indep_hp_possible()
1689 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); in indep_hp_possible()
1690 if (path && is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1693 for (i = 0; i < cfg->speaker_outs; i++) { in indep_hp_possible()
1694 path = snd_hda_get_path_from_idx(codec, spec->speaker_paths[i]); in indep_hp_possible()
1695 if (path && is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1717 dacs[i] = path->path[0]; in refill_shared_dacs()
1726 struct hda_gen_spec *spec = codec->spec; in fill_and_eval_dacs()
1727 struct auto_pin_cfg *cfg = &spec->autocfg; in fill_and_eval_dacs()
1731 spec->multiout.num_dacs = cfg->line_outs; in fill_and_eval_dacs()
1732 spec->multiout.dac_nids = spec->private_dac_nids; in fill_and_eval_dacs()
1733 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); in fill_and_eval_dacs()
1734 memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); in fill_and_eval_dacs()
1735 memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid)); in fill_and_eval_dacs()
1736 spec->multi_ios = 0; in fill_and_eval_dacs()
1737 snd_array_free(&spec->paths); in fill_and_eval_dacs()
1740 memset(spec->out_paths, 0, sizeof(spec->out_paths)); in fill_and_eval_dacs()
1741 memset(spec->hp_paths, 0, sizeof(spec->hp_paths)); in fill_and_eval_dacs()
1742 memset(spec->speaker_paths, 0, sizeof(spec->speaker_paths)); in fill_and_eval_dacs()
1743 memset(spec->aamix_out_paths, 0, sizeof(spec->aamix_out_paths)); in fill_and_eval_dacs()
1744 memset(spec->digout_paths, 0, sizeof(spec->digout_paths)); in fill_and_eval_dacs()
1745 memset(spec->input_paths, 0, sizeof(spec->input_paths)); in fill_and_eval_dacs()
1746 memset(spec->loopback_paths, 0, sizeof(spec->loopback_paths)); in fill_and_eval_dacs()
1747 memset(&spec->digin_path, 0, sizeof(spec->digin_path)); in fill_and_eval_dacs()
1751 /* fill hard-wired DACs first */ in fill_and_eval_dacs()
1755 mapped = map_singles(codec, cfg->line_outs, in fill_and_eval_dacs()
1756 cfg->line_out_pins, in fill_and_eval_dacs()
1757 spec->private_dac_nids, in fill_and_eval_dacs()
1758 spec->out_paths); in fill_and_eval_dacs()
1759 mapped |= map_singles(codec, cfg->hp_outs, in fill_and_eval_dacs()
1760 cfg->hp_pins, in fill_and_eval_dacs()
1761 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1762 spec->hp_paths); in fill_and_eval_dacs()
1763 mapped |= map_singles(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1764 cfg->speaker_pins, in fill_and_eval_dacs()
1765 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1766 spec->speaker_paths); in fill_and_eval_dacs()
1767 if (!spec->no_multi_io && in fill_and_eval_dacs()
1768 fill_mio_first && cfg->line_outs == 1 && in fill_and_eval_dacs()
1769 cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1770 err = fill_multi_ios(codec, cfg->line_out_pins[0], true); in fill_and_eval_dacs()
1777 badness += try_assign_dacs(codec, cfg->line_outs, cfg->line_out_pins, in fill_and_eval_dacs()
1778 spec->private_dac_nids, spec->out_paths, in fill_and_eval_dacs()
1779 spec->main_out_badness); in fill_and_eval_dacs()
1781 if (!spec->no_multi_io && fill_mio_first && in fill_and_eval_dacs()
1782 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1783 /* try to fill multi-io first */ in fill_and_eval_dacs()
1784 err = fill_multi_ios(codec, cfg->line_out_pins[0], false); in fill_and_eval_dacs()
1790 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in fill_and_eval_dacs()
1791 err = try_assign_dacs(codec, cfg->hp_outs, cfg->hp_pins, in fill_and_eval_dacs()
1792 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1793 spec->hp_paths, in fill_and_eval_dacs()
1794 spec->extra_out_badness); in fill_and_eval_dacs()
1799 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1800 err = try_assign_dacs(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1801 cfg->speaker_pins, in fill_and_eval_dacs()
1802 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1803 spec->speaker_paths, in fill_and_eval_dacs()
1804 spec->extra_out_badness); in fill_and_eval_dacs()
1809 if (!spec->no_multi_io && in fill_and_eval_dacs()
1810 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1811 err = fill_multi_ios(codec, cfg->line_out_pins[0], false); in fill_and_eval_dacs()
1817 if (spec->mixer_nid) { in fill_and_eval_dacs()
1818 spec->aamix_out_paths[0] = in fill_and_eval_dacs()
1819 check_aamix_out_path(codec, spec->out_paths[0]); in fill_and_eval_dacs()
1820 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in fill_and_eval_dacs()
1821 spec->aamix_out_paths[1] = in fill_and_eval_dacs()
1822 check_aamix_out_path(codec, spec->hp_paths[0]); in fill_and_eval_dacs()
1823 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1824 spec->aamix_out_paths[2] = in fill_and_eval_dacs()
1825 check_aamix_out_path(codec, spec->speaker_paths[0]); in fill_and_eval_dacs()
1828 if (!spec->no_multi_io && in fill_and_eval_dacs()
1829 cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1830 if (count_multiio_pins(codec, cfg->hp_pins[0]) >= 2) in fill_and_eval_dacs()
1831 spec->multi_ios = 1; /* give badness */ in fill_and_eval_dacs()
1833 /* re-count num_dacs and squash invalid entries */ in fill_and_eval_dacs()
1834 spec->multiout.num_dacs = 0; in fill_and_eval_dacs()
1835 for (i = 0; i < cfg->line_outs; i++) { in fill_and_eval_dacs()
1836 if (spec->private_dac_nids[i]) in fill_and_eval_dacs()
1837 spec->multiout.num_dacs++; in fill_and_eval_dacs()
1839 memmove(spec->private_dac_nids + i, in fill_and_eval_dacs()
1840 spec->private_dac_nids + i + 1, in fill_and_eval_dacs()
1841 sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); in fill_and_eval_dacs()
1842 spec->private_dac_nids[cfg->line_outs - 1] = 0; in fill_and_eval_dacs()
1846 spec->ext_channel_count = spec->min_channel_count = in fill_and_eval_dacs()
1847 spec->multiout.num_dacs * 2; in fill_and_eval_dacs()
1849 if (spec->multi_ios == 2) { in fill_and_eval_dacs()
1851 spec->private_dac_nids[spec->multiout.num_dacs++] = in fill_and_eval_dacs()
1852 spec->multi_io[i].dac; in fill_and_eval_dacs()
1853 } else if (spec->multi_ios) { in fill_and_eval_dacs()
1854 spec->multi_ios = 0; in fill_and_eval_dacs()
1858 if (spec->indep_hp && !indep_hp_possible(codec)) in fill_and_eval_dacs()
1861 /* re-fill the shared DAC for speaker / headphone */ in fill_and_eval_dacs()
1862 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in fill_and_eval_dacs()
1863 refill_shared_dacs(codec, cfg->hp_outs, in fill_and_eval_dacs()
1864 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1865 spec->hp_paths); in fill_and_eval_dacs()
1866 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1867 refill_shared_dacs(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1868 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1869 spec->speaker_paths); in fill_and_eval_dacs()
1898 struct hda_gen_spec *spec = codec->spec; in debug_show_configs()
1903 cfg->line_out_pins[0], cfg->line_out_pins[1], in debug_show_configs()
1904 cfg->line_out_pins[2], cfg->line_out_pins[3], in debug_show_configs()
1905 spec->multiout.dac_nids[0], in debug_show_configs()
1906 spec->multiout.dac_nids[1], in debug_show_configs()
1907 spec->multiout.dac_nids[2], in debug_show_configs()
1908 spec->multiout.dac_nids[3], in debug_show_configs()
1909 lo_type[cfg->line_out_type]); in debug_show_configs()
1910 for (i = 0; i < cfg->line_outs; i++) in debug_show_configs()
1911 print_nid_path_idx(codec, " out", spec->out_paths[i]); in debug_show_configs()
1912 if (spec->multi_ios > 0) in debug_show_configs()
1914 spec->multi_ios, in debug_show_configs()
1915 spec->multi_io[0].pin, spec->multi_io[1].pin, in debug_show_configs()
1916 spec->multi_io[0].dac, spec->multi_io[1].dac); in debug_show_configs()
1917 for (i = 0; i < spec->multi_ios; i++) in debug_show_configs()
1919 spec->out_paths[cfg->line_outs + i]); in debug_show_configs()
1920 if (cfg->hp_outs) in debug_show_configs()
1922 cfg->hp_pins[0], cfg->hp_pins[1], in debug_show_configs()
1923 cfg->hp_pins[2], cfg->hp_pins[3], in debug_show_configs()
1924 spec->multiout.hp_out_nid[0], in debug_show_configs()
1925 spec->multiout.hp_out_nid[1], in debug_show_configs()
1926 spec->multiout.hp_out_nid[2], in debug_show_configs()
1927 spec->multiout.hp_out_nid[3]); in debug_show_configs()
1928 for (i = 0; i < cfg->hp_outs; i++) in debug_show_configs()
1929 print_nid_path_idx(codec, " hp ", spec->hp_paths[i]); in debug_show_configs()
1930 if (cfg->speaker_outs) in debug_show_configs()
1932 cfg->speaker_pins[0], cfg->speaker_pins[1], in debug_show_configs()
1933 cfg->speaker_pins[2], cfg->speaker_pins[3], in debug_show_configs()
1934 spec->multiout.extra_out_nid[0], in debug_show_configs()
1935 spec->multiout.extra_out_nid[1], in debug_show_configs()
1936 spec->multiout.extra_out_nid[2], in debug_show_configs()
1937 spec->multiout.extra_out_nid[3]); in debug_show_configs()
1938 for (i = 0; i < cfg->speaker_outs; i++) in debug_show_configs()
1939 print_nid_path_idx(codec, " spk", spec->speaker_paths[i]); in debug_show_configs()
1941 print_nid_path_idx(codec, " mix", spec->aamix_out_paths[i]); in debug_show_configs()
1950 struct hda_gen_spec *spec = codec->spec; in fill_all_dac_nids()
1953 spec->num_all_dacs = 0; in fill_all_dac_nids()
1954 memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); in fill_all_dac_nids()
1958 if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { in fill_all_dac_nids()
1962 spec->all_dacs[spec->num_all_dacs++] = nid; in fill_all_dac_nids()
1968 struct hda_gen_spec *spec = codec->spec; in parse_output_paths()
1969 struct auto_pin_cfg *cfg = &spec->autocfg; in parse_output_paths()
1980 return -ENOMEM; in parse_output_paths()
1991 cfg->line_out_type, fill_hardwired, fill_mio_first, in parse_output_paths()
2011 if (cfg->speaker_outs > 0 && in parse_output_paths()
2012 cfg->line_out_type == AUTO_PIN_HP_OUT) { in parse_output_paths()
2013 cfg->hp_outs = cfg->line_outs; in parse_output_paths()
2014 memcpy(cfg->hp_pins, cfg->line_out_pins, in parse_output_paths()
2015 sizeof(cfg->hp_pins)); in parse_output_paths()
2016 cfg->line_outs = cfg->speaker_outs; in parse_output_paths()
2017 memcpy(cfg->line_out_pins, cfg->speaker_pins, in parse_output_paths()
2018 sizeof(cfg->speaker_pins)); in parse_output_paths()
2019 cfg->speaker_outs = 0; in parse_output_paths()
2020 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); in parse_output_paths()
2021 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; in parse_output_paths()
2025 if (cfg->hp_outs > 0 && in parse_output_paths()
2026 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { in parse_output_paths()
2027 cfg->speaker_outs = cfg->line_outs; in parse_output_paths()
2028 memcpy(cfg->speaker_pins, cfg->line_out_pins, in parse_output_paths()
2029 sizeof(cfg->speaker_pins)); in parse_output_paths()
2030 cfg->line_outs = cfg->hp_outs; in parse_output_paths()
2031 memcpy(cfg->line_out_pins, cfg->hp_pins, in parse_output_paths()
2032 sizeof(cfg->hp_pins)); in parse_output_paths()
2033 cfg->hp_outs = 0; in parse_output_paths()
2034 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); in parse_output_paths()
2035 cfg->line_out_type = AUTO_PIN_HP_OUT; in parse_output_paths()
2048 cfg->line_out_type, best_wired, best_mio); in parse_output_paths()
2051 if (cfg->line_out_pins[0]) { in parse_output_paths()
2053 path = snd_hda_get_path_from_idx(codec, spec->out_paths[0]); in parse_output_paths()
2055 spec->vmaster_nid = look_for_out_vol_nid(codec, path); in parse_output_paths()
2056 if (spec->vmaster_nid) { in parse_output_paths()
2057 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, in parse_output_paths()
2058 HDA_OUTPUT, spec->vmaster_tlv); in parse_output_paths()
2059 if (spec->dac_min_mute) in parse_output_paths()
2060 spec->vmaster_tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] |= TLV_DB_SCALE_MUTE; in parse_output_paths()
2065 if (spec->prefer_hp_amp || cfg->line_out_type == AUTO_PIN_HP_OUT) in parse_output_paths()
2069 set_pin_targets(codec, cfg->line_outs, cfg->line_out_pins, val); in parse_output_paths()
2070 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in parse_output_paths()
2071 set_pin_targets(codec, cfg->hp_outs, cfg->hp_pins, PIN_HP); in parse_output_paths()
2072 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in parse_output_paths()
2073 val = spec->prefer_hp_amp ? PIN_HP : PIN_OUT; in parse_output_paths()
2074 set_pin_targets(codec, cfg->speaker_outs, in parse_output_paths()
2075 cfg->speaker_pins, val); in parse_output_paths()
2079 if (spec->indep_hp && !indep_hp_possible(codec)) in parse_output_paths()
2080 spec->indep_hp = 0; in parse_output_paths()
2090 struct hda_gen_spec *spec = codec->spec; in create_multi_out_ctls()
2093 noutputs = cfg->line_outs; in create_multi_out_ctls()
2094 if (spec->multi_ios > 0 && cfg->line_outs < 3) in create_multi_out_ctls()
2095 noutputs += spec->multi_ios; in create_multi_out_ctls()
2102 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); in create_multi_out_ctls()
2186 struct hda_gen_spec *spec = codec->spec; in create_hp_out_ctls()
2187 return create_extra_outs(codec, spec->autocfg.hp_outs, in create_hp_out_ctls()
2188 spec->hp_paths, in create_hp_out_ctls()
2194 struct hda_gen_spec *spec = codec->spec; in create_speaker_out_ctls()
2195 return create_extra_outs(codec, spec->autocfg.speaker_outs, in create_speaker_out_ctls()
2196 spec->speaker_paths, in create_speaker_out_ctls()
2216 struct hda_gen_spec *spec = codec->spec; in indep_hp_get()
2217 ucontrol->value.enumerated.item[0] = spec->indep_hp_enabled; in indep_hp_get()
2229 struct hda_gen_spec *spec = codec->spec; in indep_hp_put()
2230 unsigned int select = ucontrol->value.enumerated.item[0]; in indep_hp_put()
2233 mutex_lock(&spec->pcm_mutex); in indep_hp_put()
2234 if (spec->active_streams) { in indep_hp_put()
2235 ret = -EBUSY; in indep_hp_put()
2239 if (spec->indep_hp_enabled != select) { in indep_hp_put()
2241 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in indep_hp_put()
2242 dacp = &spec->private_dac_nids[0]; in indep_hp_put()
2244 dacp = &spec->multiout.hp_out_nid[0]; in indep_hp_put()
2247 if (spec->have_aamix_ctl) { in indep_hp_put()
2248 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in indep_hp_put()
2249 update_aamix_paths(codec, spec->aamix_mode, in indep_hp_put()
2250 spec->out_paths[0], in indep_hp_put()
2251 spec->aamix_out_paths[0], in indep_hp_put()
2252 spec->autocfg.line_out_type); in indep_hp_put()
2254 update_aamix_paths(codec, spec->aamix_mode, in indep_hp_put()
2255 spec->hp_paths[0], in indep_hp_put()
2256 spec->aamix_out_paths[1], in indep_hp_put()
2260 spec->indep_hp_enabled = select; in indep_hp_put()
2261 if (spec->indep_hp_enabled) in indep_hp_put()
2264 *dacp = spec->alt_dac_nid; in indep_hp_put()
2270 mutex_unlock(&spec->pcm_mutex); in indep_hp_put()
2285 struct hda_gen_spec *spec = codec->spec; in create_indep_hp_ctls()
2288 if (!spec->indep_hp) in create_indep_hp_ctls()
2290 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in create_indep_hp_ctls()
2291 dac = spec->multiout.dac_nids[0]; in create_indep_hp_ctls()
2293 dac = spec->multiout.hp_out_nid[0]; in create_indep_hp_ctls()
2295 spec->indep_hp = 0; in create_indep_hp_ctls()
2299 spec->indep_hp_enabled = false; in create_indep_hp_ctls()
2300 spec->alt_dac_nid = dac; in create_indep_hp_ctls()
2302 return -ENOMEM; in create_indep_hp_ctls()
2314 struct hda_gen_spec *spec = codec->spec; in ch_mode_info()
2317 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ch_mode_info()
2318 uinfo->count = 1; in ch_mode_info()
2319 uinfo->value.enumerated.items = spec->multi_ios + 1; in ch_mode_info()
2320 if (uinfo->value.enumerated.item > spec->multi_ios) in ch_mode_info()
2321 uinfo->value.enumerated.item = spec->multi_ios; in ch_mode_info()
2322 chs = uinfo->value.enumerated.item * 2 + spec->min_channel_count; in ch_mode_info()
2323 sprintf(uinfo->value.enumerated.name, "%dch", chs); in ch_mode_info()
2331 struct hda_gen_spec *spec = codec->spec; in ch_mode_get()
2332 ucontrol->value.enumerated.item[0] = in ch_mode_get()
2333 (spec->ext_channel_count - spec->min_channel_count) / 2; in ch_mode_get()
2340 struct hda_gen_spec *spec = codec->spec; in get_multiio_path()
2342 spec->out_paths[spec->autocfg.line_outs + idx]); in get_multiio_path()
2352 return !spec->have_aamix_ctl || spec->aamix_mode; in aamix_default()
2357 struct hda_gen_spec *spec = codec->spec; in set_multi_io()
2358 hda_nid_t nid = spec->multi_io[idx].pin; in set_multi_io()
2363 return -EINVAL; in set_multi_io()
2365 if (path->active == output) in set_multi_io()
2375 set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true); in set_multi_io()
2389 struct hda_gen_spec *spec = codec->spec; in ch_mode_put()
2392 ch = ucontrol->value.enumerated.item[0]; in ch_mode_put()
2393 if (ch < 0 || ch > spec->multi_ios) in ch_mode_put()
2394 return -EINVAL; in ch_mode_put()
2395 if (ch == (spec->ext_channel_count - spec->min_channel_count) / 2) in ch_mode_put()
2397 spec->ext_channel_count = ch * 2 + spec->min_channel_count; in ch_mode_put()
2398 for (i = 0; i < spec->multi_ios; i++) in ch_mode_put()
2400 spec->multiout.max_channels = max(spec->ext_channel_count, in ch_mode_put()
2401 spec->const_channel_count); in ch_mode_put()
2402 if (spec->need_dac_fix) in ch_mode_put()
2403 spec->multiout.num_dacs = spec->multiout.max_channels / 2; in ch_mode_put()
2417 struct hda_gen_spec *spec = codec->spec; in create_multi_channel_mode()
2419 if (spec->multi_ios > 0) { in create_multi_channel_mode()
2421 return -ENOMEM; in create_multi_channel_mode()
2436 struct hda_gen_spec *spec = codec->spec; in loopback_mixing_get()
2437 ucontrol->value.enumerated.item[0] = spec->aamix_mode; in loopback_mixing_get()
2445 struct hda_gen_spec *spec = codec->spec; in update_aamix_paths()
2456 if (out_type == AUTO_PIN_HP_OUT && spec->indep_hp_enabled && in update_aamix_paths()
2457 mix_path->path[0] != spec->alt_dac_nid) in update_aamix_paths()
2471 /* re-initialize the output paths; only called from loopback_mixing_put() */
2475 struct hda_gen_spec *spec = codec->spec; in update_output_paths()
2482 snd_hda_activate_path(codec, path, path->active, in update_output_paths()
2483 spec->aamix_mode); in update_output_paths()
2491 struct hda_gen_spec *spec = codec->spec; in loopback_mixing_put()
2492 const struct auto_pin_cfg *cfg = &spec->autocfg; in loopback_mixing_put()
2493 unsigned int val = ucontrol->value.enumerated.item[0]; in loopback_mixing_put()
2495 if (val == spec->aamix_mode) in loopback_mixing_put()
2497 spec->aamix_mode = val; in loopback_mixing_put()
2499 update_aamix_paths(codec, val, spec->out_paths[0], in loopback_mixing_put()
2500 spec->aamix_out_paths[0], in loopback_mixing_put()
2501 cfg->line_out_type); in loopback_mixing_put()
2502 update_aamix_paths(codec, val, spec->hp_paths[0], in loopback_mixing_put()
2503 spec->aamix_out_paths[1], in loopback_mixing_put()
2505 update_aamix_paths(codec, val, spec->speaker_paths[0], in loopback_mixing_put()
2506 spec->aamix_out_paths[2], in loopback_mixing_put()
2509 update_output_paths(codec, cfg->line_outs, spec->out_paths); in loopback_mixing_put()
2510 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in loopback_mixing_put()
2511 update_output_paths(codec, cfg->hp_outs, spec->hp_paths); in loopback_mixing_put()
2512 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in loopback_mixing_put()
2513 update_output_paths(codec, cfg->speaker_outs, in loopback_mixing_put()
2514 spec->speaker_paths); in loopback_mixing_put()
2529 struct hda_gen_spec *spec = codec->spec; in create_loopback_mixing_ctl()
2531 if (!spec->mixer_nid) in create_loopback_mixing_ctl()
2534 return -ENOMEM; in create_loopback_mixing_ctl()
2535 spec->have_aamix_ctl = 1; in create_loopback_mixing_ctl()
2545 /* for shared I/O, change the pin-control accordingly */
2548 struct hda_gen_spec *spec = codec->spec; in update_hp_mic()
2553 pin = spec->hp_mic_pin; in update_hp_mic()
2554 as_mic = spec->cur_mux[adc_mux] == spec->hp_mic_mux_idx; in update_hp_mic()
2571 if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { in update_hp_mic()
2572 const hda_nid_t vref_pin = spec->shared_mic_vref_pin; in update_hp_mic()
2579 if (!spec->hp_mic_jack_modes) { in update_hp_mic()
2592 struct hda_gen_spec *spec = codec->spec; in create_hp_mic()
2593 struct auto_pin_cfg *cfg = &spec->autocfg; in create_hp_mic()
2597 if (!spec->hp_mic) { in create_hp_mic()
2598 if (spec->suppress_hp_mic_detect) in create_hp_mic()
2603 if (cfg->num_inputs > 1) in create_hp_mic()
2605 else if (cfg->num_inputs == 1) { in create_hp_mic()
2606 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); in create_hp_mic()
2612 spec->hp_mic = 0; /* clear once */ in create_hp_mic()
2613 if (cfg->num_inputs >= AUTO_CFG_MAX_INS) in create_hp_mic()
2617 if (cfg->line_out_type == AUTO_PIN_HP_OUT && cfg->line_outs > 0) in create_hp_mic()
2618 nid = cfg->line_out_pins[0]; in create_hp_mic()
2619 else if (cfg->hp_outs > 0) in create_hp_mic()
2620 nid = cfg->hp_pins[0]; in create_hp_mic()
2627 cfg->inputs[cfg->num_inputs].pin = nid; in create_hp_mic()
2628 cfg->inputs[cfg->num_inputs].type = AUTO_PIN_MIC; in create_hp_mic()
2629 cfg->inputs[cfg->num_inputs].is_headphone_mic = 1; in create_hp_mic()
2630 cfg->num_inputs++; in create_hp_mic()
2631 spec->hp_mic = 1; in create_hp_mic()
2632 spec->hp_mic_pin = nid; in create_hp_mic()
2633 /* we can't handle auto-mic together with HP-mic */ in create_hp_mic()
2634 spec->suppress_auto_mic = 1; in create_hp_mic()
2659 hda_nid_t nid = kcontrol->private_value; in out_jack_mode_get()
2661 ucontrol->value.enumerated.item[0] = 1; in out_jack_mode_get()
2663 ucontrol->value.enumerated.item[0] = 0; in out_jack_mode_get()
2671 hda_nid_t nid = kcontrol->private_value; in out_jack_mode_put()
2674 val = ucontrol->value.enumerated.item[0] ? PIN_HP : PIN_OUT; in out_jack_mode_put()
2690 struct hda_gen_spec *spec = codec->spec; in find_kctl_name()
2694 snd_array_for_each(&spec->kctls, i, kctl) { in find_kctl_name()
2695 if (!strcmp(kctl->name, name) && kctl->index == idx) in find_kctl_name()
2704 struct hda_gen_spec *spec = codec->spec; in get_jack_mode_name()
2707 snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len, &idx); in get_jack_mode_name()
2716 struct hda_gen_spec *spec = codec->spec; in get_out_jack_num_items()
2717 if (spec->add_jack_modes) { in get_out_jack_num_items()
2728 struct hda_gen_spec *spec = codec->spec; in create_out_jack_modes()
2733 if (pin == spec->hp_mic_pin) in create_out_jack_modes()
2742 return -ENOMEM; in create_out_jack_modes()
2743 knew->private_value = pin; in create_out_jack_modes()
2806 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_info()
2812 strcpy(uinfo->value.enumerated.name, in in_jack_mode_info()
2813 vref_texts[get_vref_idx(vref_caps, uinfo->value.enumerated.item)]); in in_jack_mode_info()
2821 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_get()
2826 ucontrol->value.enumerated.item[0] = cvt_from_vref_idx(vref_caps, idx); in in_jack_mode_get()
2834 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_put()
2840 if (idx == ucontrol->value.enumerated.item[0]) in in_jack_mode_put()
2844 val |= get_vref_idx(vref_caps, ucontrol->value.enumerated.item[0]); in in_jack_mode_put()
2858 struct hda_gen_spec *spec = codec->spec; in get_in_jack_num_items()
2860 if (spec->add_jack_modes) in get_in_jack_num_items()
2867 struct hda_gen_spec *spec = codec->spec; in create_in_jack_mode()
2872 if (pin == spec->hp_mic_pin) in create_in_jack_mode()
2887 return -ENOMEM; in create_in_jack_mode()
2888 knew->private_value = pin; in create_in_jack_mode()
2899 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_info()
2905 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in hp_mic_jack_mode_info()
2906 uinfo->count = 1; in hp_mic_jack_mode_info()
2907 uinfo->value.enumerated.items = out_jacks + in_jacks; in hp_mic_jack_mode_info()
2908 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) in hp_mic_jack_mode_info()
2909 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; in hp_mic_jack_mode_info()
2910 idx = uinfo->value.enumerated.item; in hp_mic_jack_mode_info()
2917 idx -= out_jacks; in hp_mic_jack_mode_info()
2925 strcpy(uinfo->value.enumerated.name, text); in hp_mic_jack_mode_info()
2954 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_get()
2955 ucontrol->value.enumerated.item[0] = in hp_mic_jack_mode_get()
2964 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_put()
2970 idx = ucontrol->value.enumerated.item[0]; in hp_mic_jack_mode_put()
2980 idx -= out_jacks; in hp_mic_jack_mode_put()
3004 struct hda_gen_spec *spec = codec->spec; in create_hp_mic_jack_mode()
3010 return -ENOMEM; in create_hp_mic_jack_mode()
3011 knew->private_value = pin; in create_hp_mic_jack_mode()
3012 spec->hp_mic_jack_modes = 1; in create_hp_mic_jack_mode()
3020 /* add the powersave loopback-list entry */
3025 list = snd_array_new(&spec->loopback_list); in add_loopback_list()
3027 return -ENOMEM; in add_loopback_list()
3028 list->nid = mix; in add_loopback_list()
3029 list->dir = HDA_INPUT; in add_loopback_list()
3030 list->idx = idx; in add_loopback_list()
3031 spec->loopback.amplist = spec->loopback_list.list; in add_loopback_list()
3078 struct hda_gen_spec *spec = codec->spec; in new_analog_input()
3088 return -EINVAL; in new_analog_input()
3090 spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path); in new_analog_input()
3092 idx = path->idx[path->depth - 1]; in new_analog_input()
3097 path->ctls[NID_PATH_VOL_CTL] = mix_val; in new_analog_input()
3104 path->ctls[NID_PATH_MUTE_CTL] = mute_val; in new_analog_input()
3107 path->active = true; in new_analog_input()
3108 path->stream_enabled = true; /* no DAC/ADC involved */ in new_analog_input()
3113 if (spec->mixer_nid != spec->mixer_merge_nid && in new_analog_input()
3114 !spec->loopback_merge_path) { in new_analog_input()
3115 path = snd_hda_add_new_path(codec, spec->mixer_nid, in new_analog_input()
3116 spec->mixer_merge_nid, 0); in new_analog_input()
3118 print_nid_path(codec, "loopback-merge", path); in new_analog_input()
3119 path->active = true; in new_analog_input()
3120 path->pin_fixed = true; /* static route */ in new_analog_input()
3121 path->stream_enabled = true; /* no DAC/ADC involved */ in new_analog_input()
3122 spec->loopback_merge_path = in new_analog_input()
3139 struct hda_gen_spec *spec = codec->spec; in fill_adc_nids()
3141 hda_nid_t *adc_nids = spec->adc_nids; in fill_adc_nids()
3142 int max_nums = ARRAY_SIZE(spec->adc_nids); in fill_adc_nids()
3155 spec->num_adc_nids = nums; in fill_adc_nids()
3158 spec->num_all_adcs = nums; in fill_adc_nids()
3159 memcpy(spec->all_adcs, spec->adc_nids, nums * sizeof(hda_nid_t)); in fill_adc_nids()
3165 * if needed, check whether dynamic ADC-switching is available
3169 struct hda_gen_spec *spec = codec->spec; in check_dyn_adc_switch()
3170 struct hda_input_mux *imux = &spec->input_mux; in check_dyn_adc_switch()
3176 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3177 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3178 if (!spec->input_paths[i][n]) in check_dyn_adc_switch()
3181 if (i >= imux->num_items) { in check_dyn_adc_switch()
3188 /* check whether ADC-switch is possible */ in check_dyn_adc_switch()
3189 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3190 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3191 if (spec->input_paths[i][n]) { in check_dyn_adc_switch()
3192 spec->dyn_adc_idx[i] = n; in check_dyn_adc_switch()
3199 spec->dyn_adc_switch = 1; in check_dyn_adc_switch()
3200 } else if (nums != spec->num_adc_nids) { in check_dyn_adc_switch()
3203 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3207 spec->adc_nids[nums] = spec->adc_nids[n]; in check_dyn_adc_switch()
3208 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3210 spec->input_paths[i][nums]); in check_dyn_adc_switch()
3211 spec->input_paths[i][nums] = in check_dyn_adc_switch()
3212 spec->input_paths[i][n]; in check_dyn_adc_switch()
3213 spec->input_paths[i][n] = 0; in check_dyn_adc_switch()
3218 spec->num_adc_nids = nums; in check_dyn_adc_switch()
3221 if (imux->num_items == 1 || in check_dyn_adc_switch()
3222 (imux->num_items == 2 && spec->hp_mic)) { in check_dyn_adc_switch()
3224 spec->num_adc_nids = 1; /* reduce to a single ADC */ in check_dyn_adc_switch()
3228 if (!spec->dyn_adc_switch && spec->multi_cap_vol) in check_dyn_adc_switch()
3229 spec->num_adc_nids = 1; in check_dyn_adc_switch()
3239 struct hda_gen_spec *spec = codec->spec; in parse_capture_source()
3240 struct hda_input_mux *imux = &spec->input_mux; in parse_capture_source()
3241 int imux_idx = imux->num_items; in parse_capture_source()
3247 hda_nid_t adc = spec->adc_nids[c]; in parse_capture_source()
3255 spec->input_paths[imux_idx][c] = in parse_capture_source()
3259 if (spec->hp_mic_pin == pin) in parse_capture_source()
3260 spec->hp_mic_mux_idx = imux->num_items; in parse_capture_source()
3261 spec->imux_pins[imux->num_items] = pin; in parse_capture_source()
3264 if (spec->dyn_adc_switch) in parse_capture_source()
3265 spec->dyn_adc_idx[imux_idx] = c; in parse_capture_source()
3279 struct hda_gen_spec *spec = codec->spec; in fill_input_pin_labels()
3280 const struct auto_pin_cfg *cfg = &spec->autocfg; in fill_input_pin_labels()
3283 for (i = 0; i < cfg->num_inputs; i++) { in fill_input_pin_labels()
3284 hda_nid_t pin = cfg->inputs[i].pin; in fill_input_pin_labels()
3293 for (j = i - 1; j >= 0; j--) { in fill_input_pin_labels()
3294 if (spec->input_labels[j] && in fill_input_pin_labels()
3295 !strcmp(spec->input_labels[j], label)) { in fill_input_pin_labels()
3296 idx = spec->input_label_idxs[j] + 1; in fill_input_pin_labels()
3301 spec->input_labels[i] = label; in fill_input_pin_labels()
3302 spec->input_label_idxs[i] = idx; in fill_input_pin_labels()
3308 #define CFG_IDX_MIX 99 /* a dummy cfg->input idx for stereo mix */
3312 struct hda_gen_spec *spec = codec->spec; in create_input_ctls()
3313 const struct auto_pin_cfg *cfg = &spec->autocfg; in create_input_ctls()
3314 hda_nid_t mixer = spec->mixer_nid; in create_input_ctls()
3327 for (i = 0; i < cfg->num_inputs; i++) { in create_input_ctls()
3330 pin = cfg->inputs[i].pin; in create_input_ctls()
3335 if (cfg->inputs[i].type == AUTO_PIN_MIC) in create_input_ctls()
3337 if (pin != spec->hp_mic_pin && in create_input_ctls()
3344 spec->input_labels[i], in create_input_ctls()
3345 spec->input_label_idxs[i], in create_input_ctls()
3353 spec->input_labels[i], -mixer); in create_input_ctls()
3357 if (spec->add_jack_modes) { in create_input_ctls()
3365 if (mixer && spec->add_stereo_mix_input == HDA_HINT_STEREO_MIX_ENABLE) { in create_input_ctls()
3371 spec->suppress_auto_mic = 1; in create_input_ctls()
3385 struct hda_gen_spec *spec = codec->spec; in get_input_path()
3390 if (spec->dyn_adc_switch) in get_input_path()
3391 adc_idx = spec->dyn_adc_idx[imux_idx]; in get_input_path()
3396 return snd_hda_get_path_from_idx(codec, spec->input_paths[imux_idx][adc_idx]); in get_input_path()
3406 struct hda_gen_spec *spec = codec->spec; in mux_enum_info()
3407 return snd_hda_input_mux_info(&spec->input_mux, uinfo); in mux_enum_info()
3414 struct hda_gen_spec *spec = codec->spec; in mux_enum_get()
3416 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in mux_enum_get()
3418 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; in mux_enum_get()
3426 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in mux_enum_put()
3428 ucontrol->value.enumerated.item[0]); in mux_enum_put()
3452 struct hda_gen_spec *spec = codec->spec; in cap_put_caller()
3457 imux = &spec->input_mux; in cap_put_caller()
3458 adc_idx = kcontrol->id.index; in cap_put_caller()
3459 mutex_lock(&codec->control_mutex); in cap_put_caller()
3460 for (i = 0; i < imux->num_items; i++) { in cap_put_caller()
3462 if (!path || !path->ctls[type]) in cap_put_caller()
3464 kcontrol->private_value = path->ctls[type]; in cap_put_caller()
3469 mutex_unlock(&codec->control_mutex); in cap_put_caller()
3470 if (err >= 0 && spec->cap_sync_hook) in cap_put_caller()
3471 spec->cap_sync_hook(codec, kcontrol, ucontrol); in cap_put_caller()
3525 path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0; in parse_capvol_in_path()
3527 if (depth >= path->depth) in parse_capvol_in_path()
3528 return -EINVAL; in parse_capvol_in_path()
3529 i = path->depth - depth - 1; in parse_capvol_in_path()
3530 nid = path->path[i]; in parse_capvol_in_path()
3531 if (!path->ctls[NID_PATH_VOL_CTL]) { in parse_capvol_in_path()
3533 path->ctls[NID_PATH_VOL_CTL] = in parse_capvol_in_path()
3536 int idx = path->idx[i]; in parse_capvol_in_path()
3537 if (!depth && codec->single_adc_amp) in parse_capvol_in_path()
3539 path->ctls[NID_PATH_VOL_CTL] = in parse_capvol_in_path()
3543 if (!path->ctls[NID_PATH_MUTE_CTL]) { in parse_capvol_in_path()
3545 path->ctls[NID_PATH_MUTE_CTL] = in parse_capvol_in_path()
3548 int idx = path->idx[i]; in parse_capvol_in_path()
3549 if (!depth && codec->single_adc_amp) in parse_capvol_in_path()
3551 path->ctls[NID_PATH_MUTE_CTL] = in parse_capvol_in_path()
3561 struct hda_gen_spec *spec = codec->spec; in is_inv_dmic_pin()
3562 struct auto_pin_cfg *cfg = &spec->autocfg; in is_inv_dmic_pin()
3566 if (!spec->inv_dmic_split) in is_inv_dmic_pin()
3568 for (i = 0; i < cfg->num_inputs; i++) { in is_inv_dmic_pin()
3569 if (cfg->inputs[i].pin != nid) in is_inv_dmic_pin()
3571 if (cfg->inputs[i].type != AUTO_PIN_MIC) in is_inv_dmic_pin()
3584 struct hda_gen_spec *spec = codec->spec; in cap_single_sw_put()
3591 if (spec->cap_sync_hook) in cap_single_sw_put()
3592 spec->cap_sync_hook(codec, kcontrol, ucontrol); in cap_single_sw_put()
3601 struct hda_gen_spec *spec = codec->spec; in add_single_cap_ctl()
3620 return -ENOMEM; in add_single_cap_ctl()
3622 knew->put = cap_single_sw_put; in add_single_cap_ctl()
3636 return -ENOMEM; in add_single_cap_ctl()
3638 knew->put = cap_single_sw_put; in add_single_cap_ctl()
3661 struct hda_gen_spec *spec = codec->spec; in create_bind_cap_vol_ctl()
3667 return -ENOMEM; in create_bind_cap_vol_ctl()
3668 knew->index = idx; in create_bind_cap_vol_ctl()
3669 knew->private_value = vol_ctl; in create_bind_cap_vol_ctl()
3670 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in create_bind_cap_vol_ctl()
3675 return -ENOMEM; in create_bind_cap_vol_ctl()
3676 knew->index = idx; in create_bind_cap_vol_ctl()
3677 knew->private_value = sw_ctl; in create_bind_cap_vol_ctl()
3678 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in create_bind_cap_vol_ctl()
3693 ctl = path->ctls[type]; in get_first_cap_ctl()
3696 for (i = 0; i < idx - 1; i++) { in get_first_cap_ctl()
3698 if (path && path->ctls[type] == ctl) in get_first_cap_ctl()
3707 struct hda_gen_spec *spec = codec->spec; in create_multi_cap_vol_ctl()
3708 struct hda_input_mux *imux = &spec->input_mux; in create_multi_cap_vol_ctl()
3711 for (i = 0; i < imux->num_items; i++) { in create_multi_cap_vol_ctl()
3715 idx = imux->items[i].index; in create_multi_cap_vol_ctl()
3716 if (idx >= spec->autocfg.num_inputs) in create_multi_cap_vol_ctl()
3718 inv_dmic = is_inv_dmic_pin(codec, spec->imux_pins[i]); in create_multi_cap_vol_ctl()
3722 spec->input_labels[idx], in create_multi_cap_vol_ctl()
3723 spec->input_label_idxs[idx], in create_multi_cap_vol_ctl()
3736 struct hda_gen_spec *spec = codec->spec; in create_capture_mixers()
3737 struct hda_input_mux *imux = &spec->input_mux; in create_capture_mixers()
3740 if (spec->dyn_adc_switch) in create_capture_mixers()
3743 nums = spec->num_adc_nids; in create_capture_mixers()
3745 if (!spec->auto_mic && imux->num_items > 1) { in create_capture_mixers()
3751 return -ENOMEM; in create_capture_mixers()
3752 knew->count = nums; in create_capture_mixers()
3757 bool multi_cap_vol = spec->multi_cap_vol; in create_capture_mixers()
3762 for (i = 0; i < imux->num_items; i++) { in create_capture_mixers()
3769 vol = path->ctls[NID_PATH_VOL_CTL]; in create_capture_mixers()
3770 else if (vol != path->ctls[NID_PATH_VOL_CTL]) { in create_capture_mixers()
3773 path->ctls[NID_PATH_VOL_CTL], HDA_INPUT)) in create_capture_mixers()
3777 sw = path->ctls[NID_PATH_MUTE_CTL]; in create_capture_mixers()
3778 else if (sw != path->ctls[NID_PATH_MUTE_CTL]) { in create_capture_mixers()
3781 path->ctls[NID_PATH_MUTE_CTL], HDA_INPUT)) in create_capture_mixers()
3784 if (is_inv_dmic_pin(codec, spec->imux_pins[i])) in create_capture_mixers()
3833 if (depth >= path->depth - 1) in look_for_boost_amp()
3835 nid = path->path[depth]; in look_for_boost_amp()
3840 path->idx[depth])) { in look_for_boost_amp()
3841 val = HDA_COMPOSE_AMP_VAL(nid, 3, path->idx[depth], in look_for_boost_amp()
3852 struct hda_gen_spec *spec = codec->spec; in parse_mic_boost()
3853 struct auto_pin_cfg *cfg = &spec->autocfg; in parse_mic_boost()
3854 struct hda_input_mux *imux = &spec->input_mux; in parse_mic_boost()
3857 if (!spec->num_adc_nids) in parse_mic_boost()
3860 for (i = 0; i < imux->num_items; i++) { in parse_mic_boost()
3866 idx = imux->items[i].index; in parse_mic_boost()
3867 if (idx >= imux->num_items) in parse_mic_boost()
3870 /* check only line-in and mic pins */ in parse_mic_boost()
3871 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN) in parse_mic_boost()
3884 "%s Boost Volume", spec->input_labels[idx]); in parse_mic_boost()
3886 spec->input_label_idxs[idx], val)) in parse_mic_boost()
3887 return -ENOMEM; in parse_mic_boost()
3889 path->ctls[NID_PATH_BOOST_CTL] = val; in parse_mic_boost()
3906 cdev = devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); in create_mute_led_cdev()
3908 return -ENOMEM; in create_mute_led_cdev()
3910 cdev->name = micmute ? "hda::micmute" : "hda::mute"; in create_mute_led_cdev()
3911 cdev->max_brightness = 1; in create_mute_led_cdev()
3912 cdev->default_trigger = micmute ? "audio-micmute" : "audio-mute"; in create_mute_led_cdev()
3913 cdev->brightness_set_blocking = callback; in create_mute_led_cdev()
3914 cdev->brightness = ledtrig_audio_get(micmute ? LED_AUDIO_MICMUTE : LED_AUDIO_MUTE); in create_mute_led_cdev()
3915 cdev->flags = LED_CORE_SUSPENDRESUME; in create_mute_led_cdev()
3917 return devm_led_classdev_register(&codec->core.dev, cdev); in create_mute_led_cdev()
3926 * snd_dha_gen_add_mute_led_cdev - Create a LED classdev and enable as vmaster mute LED
3934 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_add_mute_led_cdev()
3945 if (spec->vmaster_mute.hook) in snd_hda_gen_add_mute_led_cdev()
3948 spec->vmaster_mute.hook = vmaster_update_mute_led; in snd_hda_gen_add_mute_led_cdev()
3949 spec->vmaster_mute_enum = 1; in snd_hda_gen_add_mute_led_cdev()
3966 struct hda_gen_spec *spec = codec->spec; in call_micmute_led_update()
3969 switch (spec->micmute_led.led_mode) { in call_micmute_led_update()
3977 val = !!spec->micmute_led.capture; in call_micmute_led_update()
3981 val = !spec->micmute_led.capture; in call_micmute_led_update()
3985 if (val == spec->micmute_led.led_value) in call_micmute_led_update()
3987 spec->micmute_led.led_value = val; in call_micmute_led_update()
3989 spec->micmute_led.led_value ? LED_ON : LED_OFF); in call_micmute_led_update()
3996 struct hda_gen_spec *spec = codec->spec; in update_micmute_led()
3999 if (spec->micmute_led.old_hook) in update_micmute_led()
4000 spec->micmute_led.old_hook(codec, kcontrol, ucontrol); in update_micmute_led()
4004 mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in update_micmute_led()
4005 if (!strcmp("Capture Switch", ucontrol->id.name)) { in update_micmute_led()
4007 if (ucontrol->value.integer.value[0] || in update_micmute_led()
4008 ucontrol->value.integer.value[1]) in update_micmute_led()
4009 spec->micmute_led.capture |= mask; in update_micmute_led()
4011 spec->micmute_led.capture &= ~mask; in update_micmute_led()
4030 struct hda_gen_spec *spec = codec->spec; in micmute_led_mode_get()
4032 ucontrol->value.enumerated.item[0] = spec->micmute_led.led_mode; in micmute_led_mode_get()
4040 struct hda_gen_spec *spec = codec->spec; in micmute_led_mode_put()
4043 mode = ucontrol->value.enumerated.item[0]; in micmute_led_mode_put()
4046 if (mode == spec->micmute_led.led_mode) in micmute_led_mode_put()
4048 spec->micmute_led.led_mode = mode; in micmute_led_mode_put()
4055 .name = "Mic Mute-LED Mode",
4061 /* Set up the capture sync hook for controlling the mic-mute LED */
4064 struct hda_gen_spec *spec = codec->spec; in add_micmute_led_hook()
4066 spec->micmute_led.led_mode = MICMUTE_LED_FOLLOW_MUTE; in add_micmute_led_hook()
4067 spec->micmute_led.capture = 0; in add_micmute_led_hook()
4068 spec->micmute_led.led_value = 0; in add_micmute_led_hook()
4069 spec->micmute_led.old_hook = spec->cap_sync_hook; in add_micmute_led_hook()
4070 spec->cap_sync_hook = update_micmute_led; in add_micmute_led_hook()
4072 return -ENOMEM; in add_micmute_led_hook()
4077 * snd_dha_gen_add_micmute_led_cdev - Create a LED classdev and enable as mic-mute LED
4086 * LED-trigger is set up.
4099 codec_warn(codec, "failed to create a mic-mute LED cdev\n"); in snd_hda_gen_add_micmute_led_cdev()
4110 * parse digital I/Os and set up NIDs in BIOS auto-parse mode
4114 struct hda_gen_spec *spec = codec->spec; in parse_digital()
4121 for (i = 0; i < spec->autocfg.dig_outs; i++) { in parse_digital()
4122 pin = spec->autocfg.dig_out_pins[i]; in parse_digital()
4130 path->active = true; in parse_digital()
4131 path->pin_fixed = true; /* no jack detection */ in parse_digital()
4132 spec->digout_paths[i] = snd_hda_get_path_idx(codec, path); in parse_digital()
4135 spec->multiout.dig_out_nid = dig_nid; in parse_digital()
4136 spec->dig_out_type = spec->autocfg.dig_out_type[0]; in parse_digital()
4138 spec->multiout.follower_dig_outs = spec->follower_dig_outs; in parse_digital()
4139 if (nums >= ARRAY_SIZE(spec->follower_dig_outs) - 1) in parse_digital()
4141 spec->follower_dig_outs[nums - 1] = dig_nid; in parse_digital()
4146 if (spec->autocfg.dig_in_pin) { in parse_digital()
4147 pin = spec->autocfg.dig_in_pin; in parse_digital()
4157 path->active = true; in parse_digital()
4158 path->pin_fixed = true; /* no jack */ in parse_digital()
4159 spec->dig_in_nid = dig_nid; in parse_digital()
4160 spec->digin_path = snd_hda_get_path_idx(codec, path); in parse_digital()
4179 struct hda_gen_spec *spec = codec->spec; in mux_select()
4183 imux = &spec->input_mux; in mux_select()
4184 if (!imux->num_items) in mux_select()
4187 if (idx >= imux->num_items) in mux_select()
4188 idx = imux->num_items - 1; in mux_select()
4189 if (spec->cur_mux[adc_idx] == idx) in mux_select()
4192 old_path = get_input_path(codec, adc_idx, spec->cur_mux[adc_idx]); in mux_select()
4195 if (old_path->active) in mux_select()
4198 spec->cur_mux[adc_idx] = idx; in mux_select()
4200 if (spec->hp_mic) in mux_select()
4203 if (spec->dyn_adc_switch) in mux_select()
4209 if (path->active) in mux_select()
4212 if (spec->cap_sync_hook) in mux_select()
4213 spec->cap_sync_hook(codec, NULL, NULL); in mux_select()
4219 * as terminals (either start- or endpoint)
4226 struct hda_gen_spec *spec = codec->spec; in set_path_power()
4231 snd_array_for_each(&spec->paths, n, path) { in set_path_power()
4232 if (!path->depth) in set_path_power()
4234 if (path->path[0] == nid || in set_path_power()
4235 path->path[path->depth - 1] == nid) { in set_path_power()
4236 bool pin_old = path->pin_enabled; in set_path_power()
4237 bool stream_old = path->stream_enabled; in set_path_power()
4240 path->pin_enabled = pin_state; in set_path_power()
4242 path->stream_enabled = stream_state; in set_path_power()
4243 if ((!path->pin_fixed && path->pin_enabled != pin_old) in set_path_power()
4244 || path->stream_enabled != stream_old) { in set_path_power()
4273 if (!codec->power_save_node) in set_pin_power_jack()
4280 return set_path_power(codec, pin, on, -1); in set_pin_power_jack()
4287 if (jack && jack->nid) in pin_power_callback()
4289 set_pin_power_jack(codec, jack->nid, on)); in pin_power_callback()
4292 /* callback only doing power up -- called at first */
4299 /* callback only doing power down -- called at last */
4318 set_path_power(codec, pins[i], true, -1); in add_pin_power_ctls()
4327 struct hda_gen_spec *spec = codec->spec; in add_all_pin_power_ctls()
4328 struct auto_pin_cfg *cfg = &spec->autocfg; in add_all_pin_power_ctls()
4331 if (!codec->power_save_node) in add_all_pin_power_ctls()
4333 add_pin_power_ctls(codec, cfg->line_outs, cfg->line_out_pins, on); in add_all_pin_power_ctls()
4334 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in add_all_pin_power_ctls()
4335 add_pin_power_ctls(codec, cfg->hp_outs, cfg->hp_pins, on); in add_all_pin_power_ctls()
4336 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in add_all_pin_power_ctls()
4337 add_pin_power_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, on); in add_all_pin_power_ctls()
4338 for (i = 0; i < cfg->num_inputs; i++) in add_all_pin_power_ctls()
4339 add_pin_power_ctls(codec, 1, &cfg->inputs[i].pin, on); in add_all_pin_power_ctls()
4350 set_pin_power_jack(codec, pins[i], -1); in sync_pin_power_ctls()
4356 struct hda_gen_spec *spec = codec->spec; in sync_all_pin_power_ctls()
4357 struct auto_pin_cfg *cfg = &spec->autocfg; in sync_all_pin_power_ctls()
4360 if (!codec->power_save_node) in sync_all_pin_power_ctls()
4362 sync_pin_power_ctls(codec, cfg->line_outs, cfg->line_out_pins); in sync_all_pin_power_ctls()
4363 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in sync_all_pin_power_ctls()
4364 sync_pin_power_ctls(codec, cfg->hp_outs, cfg->hp_pins); in sync_all_pin_power_ctls()
4365 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in sync_all_pin_power_ctls()
4366 sync_pin_power_ctls(codec, cfg->speaker_outs, cfg->speaker_pins); in sync_all_pin_power_ctls()
4367 for (i = 0; i < cfg->num_inputs; i++) in sync_all_pin_power_ctls()
4368 sync_pin_power_ctls(codec, 1, &cfg->inputs[i].pin); in sync_all_pin_power_ctls()
4375 struct hda_gen_spec *spec = codec->spec; in add_fake_paths()
4384 path = snd_array_new(&spec->paths); in add_fake_paths()
4386 return -ENOMEM; in add_fake_paths()
4388 path->depth = 2; in add_fake_paths()
4389 path->path[0] = nid; in add_fake_paths()
4390 path->path[1] = pins[i]; in add_fake_paths()
4391 path->active = true; in add_fake_paths()
4399 struct hda_gen_spec *spec = codec->spec; in add_fake_beep_paths()
4400 struct auto_pin_cfg *cfg = &spec->autocfg; in add_fake_beep_paths()
4401 hda_nid_t nid = spec->beep_nid; in add_fake_beep_paths()
4404 if (!codec->power_save_node || !nid) in add_fake_beep_paths()
4406 err = add_fake_paths(codec, nid, cfg->line_outs, cfg->line_out_pins); in add_fake_beep_paths()
4409 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in add_fake_beep_paths()
4410 err = add_fake_paths(codec, nid, cfg->hp_outs, cfg->hp_pins); in add_fake_beep_paths()
4414 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in add_fake_beep_paths()
4415 err = add_fake_paths(codec, nid, cfg->speaker_outs, in add_fake_beep_paths()
4416 cfg->speaker_pins); in add_fake_beep_paths()
4426 set_path_power(beep->codec, beep->nid, -1, on); in beep_power_hook()
4430 * snd_hda_gen_fix_pin_power - Fix the power of the given pin widget to D0
4436 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_fix_pin_power()
4439 path = snd_array_new(&spec->paths); in snd_hda_gen_fix_pin_power()
4441 return -ENOMEM; in snd_hda_gen_fix_pin_power()
4443 path->depth = 1; in snd_hda_gen_fix_pin_power()
4444 path->path[0] = pin; in snd_hda_gen_fix_pin_power()
4445 path->active = true; in snd_hda_gen_fix_pin_power()
4446 path->pin_fixed = true; in snd_hda_gen_fix_pin_power()
4447 path->stream_enabled = true; in snd_hda_gen_fix_pin_power()
4453 * Jack detections for HP auto-mute and mic-switch
4475 /* standard HP/line-out auto-mute helper */
4479 struct hda_gen_spec *spec = codec->spec; in do_automute()
4492 if (spec->auto_mute_via_amp) { in do_automute()
4499 mute_nid = get_amp_nid_(path->ctls[NID_PATH_MUTE_CTL]); in do_automute()
4503 spec->mute_bits |= (1ULL << mute_nid); in do_automute()
4505 spec->mute_bits &= ~(1ULL << mute_nid); in do_automute()
4511 if (spec->keep_vref_in_automute) in do_automute()
4526 if (codec->power_save_node) { in do_automute()
4530 set_path_power(codec, nid, on, -1); in do_automute()
4536 * snd_hda_gen_update_outputs - Toggle outputs muting
4543 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_update_outputs()
4551 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in snd_hda_gen_update_outputs()
4552 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4554 paths = spec->hp_paths; in snd_hda_gen_update_outputs()
4555 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), in snd_hda_gen_update_outputs()
4556 spec->autocfg.hp_pins, paths, spec->master_mute); in snd_hda_gen_update_outputs()
4558 if (!spec->automute_speaker) in snd_hda_gen_update_outputs()
4561 on = spec->hp_jack_present | spec->line_jack_present; in snd_hda_gen_update_outputs()
4562 on |= spec->master_mute; in snd_hda_gen_update_outputs()
4563 spec->speaker_muted = on; in snd_hda_gen_update_outputs()
4564 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_update_outputs()
4565 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4567 paths = spec->speaker_paths; in snd_hda_gen_update_outputs()
4568 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), in snd_hda_gen_update_outputs()
4569 spec->autocfg.speaker_pins, paths, on); in snd_hda_gen_update_outputs()
4571 /* toggle line-out mutes if needed, too */ in snd_hda_gen_update_outputs()
4573 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || in snd_hda_gen_update_outputs()
4574 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) in snd_hda_gen_update_outputs()
4576 if (!spec->automute_lo) in snd_hda_gen_update_outputs()
4579 on = spec->hp_jack_present; in snd_hda_gen_update_outputs()
4580 on |= spec->master_mute; in snd_hda_gen_update_outputs()
4581 spec->line_out_muted = on; in snd_hda_gen_update_outputs()
4582 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4583 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), in snd_hda_gen_update_outputs()
4584 spec->autocfg.line_out_pins, paths, on); in snd_hda_gen_update_outputs()
4590 struct hda_gen_spec *spec = codec->spec; in call_update_outputs()
4591 if (spec->automute_hook) in call_update_outputs()
4592 spec->automute_hook(codec); in call_update_outputs()
4596 /* sync the whole vmaster followers to reflect the new auto-mute status */ in call_update_outputs()
4597 if (spec->auto_mute_via_amp && !codec->bus->shutdown) in call_update_outputs()
4598 snd_ctl_sync_vmaster(spec->vmaster_mute.sw_kctl, false); in call_update_outputs()
4602 * snd_hda_gen_hp_automute - standard HP-automute helper
4609 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_hp_automute()
4610 hda_nid_t *pins = spec->autocfg.hp_pins; in snd_hda_gen_hp_automute()
4611 int num_pins = ARRAY_SIZE(spec->autocfg.hp_pins); in snd_hda_gen_hp_automute()
4613 /* No detection for the first HP jack during indep-HP mode */ in snd_hda_gen_hp_automute()
4614 if (spec->indep_hp_enabled) { in snd_hda_gen_hp_automute()
4616 num_pins--; in snd_hda_gen_hp_automute()
4619 spec->hp_jack_present = detect_jacks(codec, num_pins, pins); in snd_hda_gen_hp_automute()
4620 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) in snd_hda_gen_hp_automute()
4627 * snd_hda_gen_line_automute - standard line-out-automute helper
4634 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_line_automute()
4636 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_line_automute()
4639 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) in snd_hda_gen_line_automute()
4642 spec->line_jack_present = in snd_hda_gen_line_automute()
4643 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), in snd_hda_gen_line_automute()
4644 spec->autocfg.line_out_pins); in snd_hda_gen_line_automute()
4645 if (!spec->automute_speaker || !spec->detect_lo) in snd_hda_gen_line_automute()
4652 * snd_hda_gen_mic_autoswitch - standard mic auto-switch helper
4659 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_mic_autoswitch()
4662 if (!spec->auto_mic) in snd_hda_gen_mic_autoswitch()
4665 for (i = spec->am_num_entries - 1; i > 0; i--) { in snd_hda_gen_mic_autoswitch()
4666 hda_nid_t pin = spec->am_entry[i].pin; in snd_hda_gen_mic_autoswitch()
4671 mux_select(codec, 0, spec->am_entry[i].idx); in snd_hda_gen_mic_autoswitch()
4675 mux_select(codec, 0, spec->am_entry[0].idx); in snd_hda_gen_mic_autoswitch()
4683 struct hda_gen_spec *spec = codec->spec; in call_hp_automute()
4684 if (spec->hp_automute_hook) in call_hp_automute()
4685 spec->hp_automute_hook(codec, jack); in call_hp_automute()
4693 struct hda_gen_spec *spec = codec->spec; in call_line_automute()
4694 if (spec->line_automute_hook) in call_line_automute()
4695 spec->line_automute_hook(codec, jack); in call_line_automute()
4703 struct hda_gen_spec *spec = codec->spec; in call_mic_autoswitch()
4704 if (spec->mic_autoswitch_hook) in call_mic_autoswitch()
4705 spec->mic_autoswitch_hook(codec, jack); in call_mic_autoswitch()
4719 * Auto-Mute mode mixer enum support
4725 struct hda_gen_spec *spec = codec->spec; in automute_mode_info()
4730 if (spec->automute_speaker_possible && spec->automute_lo_possible) in automute_mode_info()
4739 struct hda_gen_spec *spec = codec->spec; in automute_mode_get()
4741 if (spec->automute_speaker) in automute_mode_get()
4743 if (spec->automute_lo) in automute_mode_get()
4746 ucontrol->value.enumerated.item[0] = val; in automute_mode_get()
4754 struct hda_gen_spec *spec = codec->spec; in automute_mode_put()
4756 switch (ucontrol->value.enumerated.item[0]) { in automute_mode_put()
4758 if (!spec->automute_speaker && !spec->automute_lo) in automute_mode_put()
4760 spec->automute_speaker = 0; in automute_mode_put()
4761 spec->automute_lo = 0; in automute_mode_put()
4764 if (spec->automute_speaker_possible) { in automute_mode_put()
4765 if (!spec->automute_lo && spec->automute_speaker) in automute_mode_put()
4767 spec->automute_speaker = 1; in automute_mode_put()
4768 spec->automute_lo = 0; in automute_mode_put()
4769 } else if (spec->automute_lo_possible) { in automute_mode_put()
4770 if (spec->automute_lo) in automute_mode_put()
4772 spec->automute_lo = 1; in automute_mode_put()
4774 return -EINVAL; in automute_mode_put()
4777 if (!spec->automute_lo_possible || !spec->automute_speaker_possible) in automute_mode_put()
4778 return -EINVAL; in automute_mode_put()
4779 if (spec->automute_speaker && spec->automute_lo) in automute_mode_put()
4781 spec->automute_speaker = 1; in automute_mode_put()
4782 spec->automute_lo = 1; in automute_mode_put()
4785 return -EINVAL; in automute_mode_put()
4793 .name = "Auto-Mute Mode",
4801 struct hda_gen_spec *spec = codec->spec; in add_automute_mode_enum()
4804 return -ENOMEM; in add_automute_mode_enum()
4809 * Check the availability of HP/line-out auto-mute;
4814 struct hda_gen_spec *spec = codec->spec; in check_auto_mute_availability()
4815 struct auto_pin_cfg *cfg = &spec->autocfg; in check_auto_mute_availability()
4819 if (spec->suppress_auto_mute) in check_auto_mute_availability()
4822 if (cfg->hp_pins[0]) in check_auto_mute_availability()
4824 if (cfg->line_out_pins[0]) in check_auto_mute_availability()
4826 if (cfg->speaker_pins[0]) in check_auto_mute_availability()
4831 if (!cfg->speaker_pins[0] && in check_auto_mute_availability()
4832 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { in check_auto_mute_availability()
4833 memcpy(cfg->speaker_pins, cfg->line_out_pins, in check_auto_mute_availability()
4834 sizeof(cfg->speaker_pins)); in check_auto_mute_availability()
4835 cfg->speaker_outs = cfg->line_outs; in check_auto_mute_availability()
4838 if (!cfg->hp_pins[0] && in check_auto_mute_availability()
4839 cfg->line_out_type == AUTO_PIN_HP_OUT) { in check_auto_mute_availability()
4840 memcpy(cfg->hp_pins, cfg->line_out_pins, in check_auto_mute_availability()
4841 sizeof(cfg->hp_pins)); in check_auto_mute_availability()
4842 cfg->hp_outs = cfg->line_outs; in check_auto_mute_availability()
4845 for (i = 0; i < cfg->hp_outs; i++) { in check_auto_mute_availability()
4846 hda_nid_t nid = cfg->hp_pins[i]; in check_auto_mute_availability()
4849 codec_dbg(codec, "Enable HP auto-muting on NID 0x%x\n", nid); in check_auto_mute_availability()
4852 spec->detect_hp = 1; in check_auto_mute_availability()
4855 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { in check_auto_mute_availability()
4856 if (cfg->speaker_outs) in check_auto_mute_availability()
4857 for (i = 0; i < cfg->line_outs; i++) { in check_auto_mute_availability()
4858 hda_nid_t nid = cfg->line_out_pins[i]; in check_auto_mute_availability()
4861 codec_dbg(codec, "Enable Line-Out auto-muting on NID 0x%x\n", nid); in check_auto_mute_availability()
4864 spec->detect_lo = 1; in check_auto_mute_availability()
4866 spec->automute_lo_possible = spec->detect_hp; in check_auto_mute_availability()
4869 spec->automute_speaker_possible = cfg->speaker_outs && in check_auto_mute_availability()
4870 (spec->detect_hp || spec->detect_lo); in check_auto_mute_availability()
4872 spec->automute_lo = spec->automute_lo_possible; in check_auto_mute_availability()
4873 spec->automute_speaker = spec->automute_speaker_possible; in check_auto_mute_availability()
4875 if (spec->automute_speaker_possible || spec->automute_lo_possible) { in check_auto_mute_availability()
4884 /* check whether all auto-mic pins are valid; setup indices if OK */
4887 struct hda_gen_spec *spec = codec->spec; in auto_mic_check_imux()
4891 imux = &spec->input_mux; in auto_mic_check_imux()
4892 for (i = 0; i < spec->am_num_entries; i++) { in auto_mic_check_imux()
4893 spec->am_entry[i].idx = in auto_mic_check_imux()
4894 find_idx_in_nid_list(spec->am_entry[i].pin, in auto_mic_check_imux()
4895 spec->imux_pins, imux->num_items); in auto_mic_check_imux()
4896 if (spec->am_entry[i].idx < 0) in auto_mic_check_imux()
4901 for (i = 1; i < spec->am_num_entries; i++) in auto_mic_check_imux()
4903 spec->am_entry[i].pin, in auto_mic_check_imux()
4912 return (int)(a->attr - b->attr); in compare_attr()
4916 * Check the availability of auto-mic switch;
4921 struct hda_gen_spec *spec = codec->spec; in check_auto_mic_availability()
4922 struct auto_pin_cfg *cfg = &spec->autocfg; in check_auto_mic_availability()
4926 if (spec->suppress_auto_mic) in check_auto_mic_availability()
4931 for (i = 0; i < cfg->num_inputs; i++) { in check_auto_mic_availability()
4932 hda_nid_t nid = cfg->inputs[i].pin; in check_auto_mic_availability()
4940 if (cfg->inputs[i].type != AUTO_PIN_MIC) in check_auto_mic_availability()
4946 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) in check_auto_mic_availability()
4948 if (!spec->line_in_auto_switch && in check_auto_mic_availability()
4949 cfg->inputs[i].type != AUTO_PIN_MIC) in check_auto_mic_availability()
4958 spec->am_entry[num_pins].pin = nid; in check_auto_mic_availability()
4959 spec->am_entry[num_pins].attr = attr; in check_auto_mic_availability()
4966 spec->am_num_entries = num_pins; in check_auto_mic_availability()
4970 sort(spec->am_entry, num_pins, sizeof(spec->am_entry[0]), in check_auto_mic_availability()
4976 spec->auto_mic = 1; in check_auto_mic_availability()
4977 spec->num_adc_nids = 1; in check_auto_mic_availability()
4978 spec->cur_mux[0] = spec->am_entry[0].idx; in check_auto_mic_availability()
4979 codec_dbg(codec, "Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", in check_auto_mic_availability()
4980 spec->am_entry[0].pin, in check_auto_mic_availability()
4981 spec->am_entry[1].pin, in check_auto_mic_availability()
4982 spec->am_entry[2].pin); in check_auto_mic_availability()
4988 * snd_hda_gen_path_power_filter - power_filter hook to make inactive widgets
4998 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_path_power_filter()
5000 if (!spec->power_down_unused && !codec->power_save_node) in snd_hda_gen_path_power_filter()
5002 if (power_state != AC_PWRST_D0 || nid == codec->core.afg) in snd_hda_gen_path_power_filter()
5032 * snd_hda_gen_stream_pm - Stream power management callback
5041 if (codec->power_save_node) in snd_hda_gen_stream_pm()
5042 set_path_power(codec, nid, -1, on); in snd_hda_gen_stream_pm()
5047 * snd_hda_gen_parse_auto_config - Parse the given BIOS configuration and
5058 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_parse_auto_config()
5063 if (spec->mixer_nid && !spec->mixer_merge_nid) in snd_hda_gen_parse_auto_config()
5064 spec->mixer_merge_nid = spec->mixer_nid; in snd_hda_gen_parse_auto_config()
5066 if (cfg != &spec->autocfg) { in snd_hda_gen_parse_auto_config()
5067 spec->autocfg = *cfg; in snd_hda_gen_parse_auto_config()
5068 cfg = &spec->autocfg; in snd_hda_gen_parse_auto_config()
5071 if (!spec->main_out_badness) in snd_hda_gen_parse_auto_config()
5072 spec->main_out_badness = &hda_main_out_badness; in snd_hda_gen_parse_auto_config()
5073 if (!spec->extra_out_badness) in snd_hda_gen_parse_auto_config()
5074 spec->extra_out_badness = &hda_extra_out_badness; in snd_hda_gen_parse_auto_config()
5078 if (!cfg->line_outs) { in snd_hda_gen_parse_auto_config()
5079 if (cfg->dig_outs || cfg->dig_in_pin) { in snd_hda_gen_parse_auto_config()
5080 spec->multiout.max_channels = 2; in snd_hda_gen_parse_auto_config()
5081 spec->no_analog = 1; in snd_hda_gen_parse_auto_config()
5084 if (!cfg->num_inputs && !cfg->dig_in_pin) in snd_hda_gen_parse_auto_config()
5088 if (!spec->no_primary_hp && in snd_hda_gen_parse_auto_config()
5089 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && in snd_hda_gen_parse_auto_config()
5090 cfg->line_outs <= cfg->hp_outs) { in snd_hda_gen_parse_auto_config()
5092 cfg->speaker_outs = cfg->line_outs; in snd_hda_gen_parse_auto_config()
5093 memcpy(cfg->speaker_pins, cfg->line_out_pins, in snd_hda_gen_parse_auto_config()
5094 sizeof(cfg->speaker_pins)); in snd_hda_gen_parse_auto_config()
5095 cfg->line_outs = cfg->hp_outs; in snd_hda_gen_parse_auto_config()
5096 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); in snd_hda_gen_parse_auto_config()
5097 cfg->hp_outs = 0; in snd_hda_gen_parse_auto_config()
5098 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); in snd_hda_gen_parse_auto_config()
5099 cfg->line_out_type = AUTO_PIN_HP_OUT; in snd_hda_gen_parse_auto_config()
5130 /* add power-down pin callbacks at first */ in snd_hda_gen_parse_auto_config()
5133 spec->const_channel_count = spec->ext_channel_count; in snd_hda_gen_parse_auto_config()
5135 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_parse_auto_config()
5136 spec->const_channel_count = max(spec->const_channel_count, in snd_hda_gen_parse_auto_config()
5137 cfg->speaker_outs * 2); in snd_hda_gen_parse_auto_config()
5138 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in snd_hda_gen_parse_auto_config()
5139 spec->const_channel_count = max(spec->const_channel_count, in snd_hda_gen_parse_auto_config()
5140 cfg->hp_outs * 2); in snd_hda_gen_parse_auto_config()
5141 spec->multiout.max_channels = max(spec->ext_channel_count, in snd_hda_gen_parse_auto_config()
5142 spec->const_channel_count); in snd_hda_gen_parse_auto_config()
5157 if (!spec->auto_mic && spec->mixer_nid && in snd_hda_gen_parse_auto_config()
5158 spec->add_stereo_mix_input == HDA_HINT_STEREO_MIX_AUTO && in snd_hda_gen_parse_auto_config()
5159 spec->input_mux.num_items > 1) { in snd_hda_gen_parse_auto_config()
5160 err = parse_capture_source(codec, spec->mixer_nid, in snd_hda_gen_parse_auto_config()
5161 CFG_IDX_MIX, spec->num_all_adcs, in snd_hda_gen_parse_auto_config()
5179 if (spec->hp_mic_pin && in snd_hda_gen_parse_auto_config()
5180 (spec->auto_mic || spec->input_mux.num_items == 1 || in snd_hda_gen_parse_auto_config()
5181 spec->add_jack_modes)) { in snd_hda_gen_parse_auto_config()
5182 err = create_hp_mic_jack_mode(codec, spec->hp_mic_pin); in snd_hda_gen_parse_auto_config()
5187 if (spec->add_jack_modes) { in snd_hda_gen_parse_auto_config()
5188 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in snd_hda_gen_parse_auto_config()
5189 err = create_out_jack_modes(codec, cfg->line_outs, in snd_hda_gen_parse_auto_config()
5190 cfg->line_out_pins); in snd_hda_gen_parse_auto_config()
5194 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in snd_hda_gen_parse_auto_config()
5195 err = create_out_jack_modes(codec, cfg->hp_outs, in snd_hda_gen_parse_auto_config()
5196 cfg->hp_pins); in snd_hda_gen_parse_auto_config()
5202 /* add power-up pin callbacks at last */ in snd_hda_gen_parse_auto_config()
5206 if (spec->mixer_nid) in snd_hda_gen_parse_auto_config()
5207 mute_all_mixer_nid(codec, spec->mixer_nid); in snd_hda_gen_parse_auto_config()
5212 if (spec->power_down_unused || codec->power_save_node) { in snd_hda_gen_parse_auto_config()
5213 if (!codec->power_filter) in snd_hda_gen_parse_auto_config()
5214 codec->power_filter = snd_hda_gen_path_power_filter; in snd_hda_gen_parse_auto_config()
5215 if (!codec->patch_ops.stream_pm) in snd_hda_gen_parse_auto_config()
5216 codec->patch_ops.stream_pm = snd_hda_gen_stream_pm; in snd_hda_gen_parse_auto_config()
5219 if (!spec->no_analog && spec->beep_nid) { in snd_hda_gen_parse_auto_config()
5220 err = snd_hda_attach_beep_device(codec, spec->beep_nid); in snd_hda_gen_parse_auto_config()
5223 if (codec->beep && codec->power_save_node) { in snd_hda_gen_parse_auto_config()
5227 codec->beep->power_hook = beep_power_hook; in snd_hda_gen_parse_auto_config()
5252 * snd_hda_gen_build_controls - Build controls from the parsed results
5259 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_build_controls()
5262 if (spec->kctls.used) { in snd_hda_gen_build_controls()
5263 err = snd_hda_add_new_ctls(codec, spec->kctls.list); in snd_hda_gen_build_controls()
5268 if (spec->multiout.dig_out_nid) { in snd_hda_gen_build_controls()
5270 spec->multiout.dig_out_nid, in snd_hda_gen_build_controls()
5271 spec->multiout.dig_out_nid, in snd_hda_gen_build_controls()
5272 spec->pcm_rec[1]->pcm_type); in snd_hda_gen_build_controls()
5275 if (!spec->no_analog) { in snd_hda_gen_build_controls()
5277 &spec->multiout); in snd_hda_gen_build_controls()
5280 spec->multiout.share_spdif = 1; in snd_hda_gen_build_controls()
5283 if (spec->dig_in_nid) { in snd_hda_gen_build_controls()
5284 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); in snd_hda_gen_build_controls()
5290 if (!spec->no_analog && !spec->suppress_vmaster && in snd_hda_gen_build_controls()
5293 spec->vmaster_tlv, follower_pfxs, in snd_hda_gen_build_controls()
5298 if (!spec->no_analog && !spec->suppress_vmaster && in snd_hda_gen_build_controls()
5303 true, &spec->vmaster_mute.sw_kctl); in snd_hda_gen_build_controls()
5306 if (spec->vmaster_mute.hook) { in snd_hda_gen_build_controls()
5307 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, in snd_hda_gen_build_controls()
5308 spec->vmaster_mute_enum); in snd_hda_gen_build_controls()
5309 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); in snd_hda_gen_build_controls()
5315 err = snd_hda_jack_add_kctls(codec, &spec->autocfg); in snd_hda_gen_build_controls()
5333 struct hda_gen_spec *spec = codec->spec; in call_pcm_playback_hook()
5334 if (spec->pcm_playback_hook) in call_pcm_playback_hook()
5335 spec->pcm_playback_hook(hinfo, codec, substream, action); in call_pcm_playback_hook()
5343 struct hda_gen_spec *spec = codec->spec; in call_pcm_capture_hook()
5344 if (spec->pcm_capture_hook) in call_pcm_capture_hook()
5345 spec->pcm_capture_hook(hinfo, codec, substream, action); in call_pcm_capture_hook()
5355 struct hda_gen_spec *spec = codec->spec; in playback_pcm_open()
5358 mutex_lock(&spec->pcm_mutex); in playback_pcm_open()
5360 &spec->multiout, substream, in playback_pcm_open()
5363 spec->active_streams |= 1 << STREAM_MULTI_OUT; in playback_pcm_open()
5367 mutex_unlock(&spec->pcm_mutex); in playback_pcm_open()
5377 struct hda_gen_spec *spec = codec->spec; in playback_pcm_prepare()
5380 err = snd_hda_multi_out_analog_prepare(codec, &spec->multiout, in playback_pcm_prepare()
5392 struct hda_gen_spec *spec = codec->spec; in playback_pcm_cleanup()
5395 err = snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); in playback_pcm_cleanup()
5406 struct hda_gen_spec *spec = codec->spec; in playback_pcm_close()
5407 mutex_lock(&spec->pcm_mutex); in playback_pcm_close()
5408 spec->active_streams &= ~(1 << STREAM_MULTI_OUT); in playback_pcm_close()
5411 mutex_unlock(&spec->pcm_mutex); in playback_pcm_close()
5429 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in capture_pcm_prepare()
5439 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in capture_pcm_cleanup()
5457 struct hda_gen_spec *spec = codec->spec; in alt_playback_pcm_open()
5460 mutex_lock(&spec->pcm_mutex); in alt_playback_pcm_open()
5461 if (spec->indep_hp && !spec->indep_hp_enabled) in alt_playback_pcm_open()
5462 err = -EBUSY; in alt_playback_pcm_open()
5464 spec->active_streams |= 1 << STREAM_INDEP_HP; in alt_playback_pcm_open()
5467 mutex_unlock(&spec->pcm_mutex); in alt_playback_pcm_open()
5475 struct hda_gen_spec *spec = codec->spec; in alt_playback_pcm_close()
5476 mutex_lock(&spec->pcm_mutex); in alt_playback_pcm_close()
5477 spec->active_streams &= ~(1 << STREAM_INDEP_HP); in alt_playback_pcm_close()
5480 mutex_unlock(&spec->pcm_mutex); in alt_playback_pcm_close()
5490 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in alt_playback_pcm_prepare()
5500 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in alt_playback_pcm_cleanup()
5513 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_open()
5514 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in dig_playback_pcm_open()
5523 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_prepare()
5524 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in dig_playback_pcm_prepare()
5532 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_cleanup()
5533 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); in dig_playback_pcm_cleanup()
5540 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_close()
5541 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in dig_playback_pcm_close()
5556 struct hda_gen_spec *spec = codec->spec; in alt_capture_pcm_prepare()
5558 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], in alt_capture_pcm_prepare()
5569 struct hda_gen_spec *spec = codec->spec; in alt_capture_pcm_cleanup()
5572 spec->adc_nids[substream->number + 1]); in alt_capture_pcm_cleanup()
5664 struct hda_gen_spec *spec = codec->spec; in dyn_adc_pcm_resetup()
5665 hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; in dyn_adc_pcm_resetup()
5667 if (spec->cur_adc && spec->cur_adc != new_adc) { in dyn_adc_pcm_resetup()
5669 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); in dyn_adc_pcm_resetup()
5670 spec->cur_adc = new_adc; in dyn_adc_pcm_resetup()
5672 spec->cur_adc_stream_tag, 0, in dyn_adc_pcm_resetup()
5673 spec->cur_adc_format); in dyn_adc_pcm_resetup()
5679 /* analog capture with dynamic dual-adc changes */
5686 struct hda_gen_spec *spec = codec->spec; in dyn_adc_capture_pcm_prepare()
5687 spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]]; in dyn_adc_capture_pcm_prepare()
5688 spec->cur_adc_stream_tag = stream_tag; in dyn_adc_capture_pcm_prepare()
5689 spec->cur_adc_format = format; in dyn_adc_capture_pcm_prepare()
5690 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); in dyn_adc_capture_pcm_prepare()
5699 struct hda_gen_spec *spec = codec->spec; in dyn_adc_capture_pcm_cleanup()
5700 snd_hda_codec_cleanup_stream(codec, spec->cur_adc); in dyn_adc_capture_pcm_cleanup()
5701 spec->cur_adc = 0; in dyn_adc_capture_pcm_cleanup()
5726 /* drop non-alnum chars after a space */ in fill_pcm_stream_name()
5736 /* copy PCM stream info from @default_str, and override non-NULL entries
5746 str->nid = nid; in setup_pcm_stream()
5748 if (spec_str->substreams) in setup_pcm_stream()
5749 str->substreams = spec_str->substreams; in setup_pcm_stream()
5750 if (spec_str->channels_min) in setup_pcm_stream()
5751 str->channels_min = spec_str->channels_min; in setup_pcm_stream()
5752 if (spec_str->channels_max) in setup_pcm_stream()
5753 str->channels_max = spec_str->channels_max; in setup_pcm_stream()
5754 if (spec_str->rates) in setup_pcm_stream()
5755 str->rates = spec_str->rates; in setup_pcm_stream()
5756 if (spec_str->formats) in setup_pcm_stream()
5757 str->formats = spec_str->formats; in setup_pcm_stream()
5758 if (spec_str->maxbps) in setup_pcm_stream()
5759 str->maxbps = spec_str->maxbps; in setup_pcm_stream()
5764 * snd_hda_gen_build_pcms - build PCM streams based on the parsed results
5771 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_build_pcms()
5775 if (spec->no_analog) in snd_hda_gen_build_pcms()
5778 fill_pcm_stream_name(spec->stream_name_analog, in snd_hda_gen_build_pcms()
5779 sizeof(spec->stream_name_analog), in snd_hda_gen_build_pcms()
5780 " Analog", codec->core.chip_name); in snd_hda_gen_build_pcms()
5781 info = snd_hda_codec_pcm_new(codec, "%s", spec->stream_name_analog); in snd_hda_gen_build_pcms()
5783 return -ENOMEM; in snd_hda_gen_build_pcms()
5784 spec->pcm_rec[0] = info; in snd_hda_gen_build_pcms()
5786 if (spec->multiout.num_dacs > 0) { in snd_hda_gen_build_pcms()
5787 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5789 spec->stream_analog_playback, in snd_hda_gen_build_pcms()
5790 spec->multiout.dac_nids[0]); in snd_hda_gen_build_pcms()
5791 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = in snd_hda_gen_build_pcms()
5792 spec->multiout.max_channels; in snd_hda_gen_build_pcms()
5793 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && in snd_hda_gen_build_pcms()
5794 spec->autocfg.line_outs == 2) in snd_hda_gen_build_pcms()
5795 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = in snd_hda_gen_build_pcms()
5798 if (spec->num_adc_nids) { in snd_hda_gen_build_pcms()
5799 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5800 (spec->dyn_adc_switch ? in snd_hda_gen_build_pcms()
5802 spec->stream_analog_capture, in snd_hda_gen_build_pcms()
5803 spec->adc_nids[0]); in snd_hda_gen_build_pcms()
5808 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { in snd_hda_gen_build_pcms()
5809 fill_pcm_stream_name(spec->stream_name_digital, in snd_hda_gen_build_pcms()
5810 sizeof(spec->stream_name_digital), in snd_hda_gen_build_pcms()
5811 " Digital", codec->core.chip_name); in snd_hda_gen_build_pcms()
5813 spec->stream_name_digital); in snd_hda_gen_build_pcms()
5815 return -ENOMEM; in snd_hda_gen_build_pcms()
5816 codec->follower_dig_outs = spec->multiout.follower_dig_outs; in snd_hda_gen_build_pcms()
5817 spec->pcm_rec[1] = info; in snd_hda_gen_build_pcms()
5818 if (spec->dig_out_type) in snd_hda_gen_build_pcms()
5819 info->pcm_type = spec->dig_out_type; in snd_hda_gen_build_pcms()
5821 info->pcm_type = HDA_PCM_TYPE_SPDIF; in snd_hda_gen_build_pcms()
5822 if (spec->multiout.dig_out_nid) in snd_hda_gen_build_pcms()
5823 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5825 spec->stream_digital_playback, in snd_hda_gen_build_pcms()
5826 spec->multiout.dig_out_nid); in snd_hda_gen_build_pcms()
5827 if (spec->dig_in_nid) in snd_hda_gen_build_pcms()
5828 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5830 spec->stream_digital_capture, in snd_hda_gen_build_pcms()
5831 spec->dig_in_nid); in snd_hda_gen_build_pcms()
5834 if (spec->no_analog) in snd_hda_gen_build_pcms()
5838 * model, configure a second analog capture-only PCM. in snd_hda_gen_build_pcms()
5840 have_multi_adcs = (spec->num_adc_nids > 1) && in snd_hda_gen_build_pcms()
5841 !spec->dyn_adc_switch && !spec->auto_mic; in snd_hda_gen_build_pcms()
5843 if (spec->alt_dac_nid || have_multi_adcs) { in snd_hda_gen_build_pcms()
5844 fill_pcm_stream_name(spec->stream_name_alt_analog, in snd_hda_gen_build_pcms()
5845 sizeof(spec->stream_name_alt_analog), in snd_hda_gen_build_pcms()
5846 " Alt Analog", codec->core.chip_name); in snd_hda_gen_build_pcms()
5848 spec->stream_name_alt_analog); in snd_hda_gen_build_pcms()
5850 return -ENOMEM; in snd_hda_gen_build_pcms()
5851 spec->pcm_rec[2] = info; in snd_hda_gen_build_pcms()
5852 if (spec->alt_dac_nid) in snd_hda_gen_build_pcms()
5853 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5855 spec->stream_analog_alt_playback, in snd_hda_gen_build_pcms()
5856 spec->alt_dac_nid); in snd_hda_gen_build_pcms()
5858 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5861 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5863 spec->stream_analog_alt_capture, in snd_hda_gen_build_pcms()
5864 spec->adc_nids[1]); in snd_hda_gen_build_pcms()
5865 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = in snd_hda_gen_build_pcms()
5866 spec->num_adc_nids - 1; in snd_hda_gen_build_pcms()
5868 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5879 * Standard auto-parser initializations
5889 if (!path || !path->depth) in set_output_and_unmute()
5891 pin = path->path[path->depth - 1]; in set_output_and_unmute()
5893 snd_hda_activate_path(codec, path, path->active, in set_output_and_unmute()
5894 aamix_default(codec->spec)); in set_output_and_unmute()
5895 set_pin_eapd(codec, pin, path->active); in set_output_and_unmute()
5901 struct hda_gen_spec *spec = codec->spec; in init_multi_out()
5904 for (i = 0; i < spec->autocfg.line_outs; i++) in init_multi_out()
5905 set_output_and_unmute(codec, spec->out_paths[i]); in init_multi_out()
5920 struct hda_gen_spec *spec = codec->spec; in init_extra_out()
5922 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) in init_extra_out()
5923 __init_extra_out(codec, spec->autocfg.hp_outs, spec->hp_paths); in init_extra_out()
5924 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) in init_extra_out()
5925 __init_extra_out(codec, spec->autocfg.speaker_outs, in init_extra_out()
5926 spec->speaker_paths); in init_extra_out()
5929 /* initialize multi-io paths */
5932 struct hda_gen_spec *spec = codec->spec; in init_multi_io()
5935 for (i = 0; i < spec->multi_ios; i++) { in init_multi_io()
5936 hda_nid_t pin = spec->multi_io[i].pin; in init_multi_io()
5941 if (!spec->multi_io[i].ctl_in) in init_multi_io()
5942 spec->multi_io[i].ctl_in = in init_multi_io()
5944 snd_hda_activate_path(codec, path, path->active, in init_multi_io()
5951 struct hda_gen_spec *spec = codec->spec; in init_aamix_paths()
5953 if (!spec->have_aamix_ctl) in init_aamix_paths()
5957 update_aamix_paths(codec, spec->aamix_mode, spec->out_paths[0], in init_aamix_paths()
5958 spec->aamix_out_paths[0], in init_aamix_paths()
5959 spec->autocfg.line_out_type); in init_aamix_paths()
5960 update_aamix_paths(codec, spec->aamix_mode, spec->hp_paths[0], in init_aamix_paths()
5961 spec->aamix_out_paths[1], in init_aamix_paths()
5963 update_aamix_paths(codec, spec->aamix_mode, spec->speaker_paths[0], in init_aamix_paths()
5964 spec->aamix_out_paths[2], in init_aamix_paths()
5971 struct hda_gen_spec *spec = codec->spec; in init_analog_input()
5972 struct auto_pin_cfg *cfg = &spec->autocfg; in init_analog_input()
5975 for (i = 0; i < cfg->num_inputs; i++) { in init_analog_input()
5976 hda_nid_t nid = cfg->inputs[i].pin; in init_analog_input()
5981 if (spec->mixer_nid) { in init_analog_input()
5982 resume_path_from_idx(codec, spec->loopback_paths[i]); in init_analog_input()
5983 resume_path_from_idx(codec, spec->loopback_merge_path); in init_analog_input()
5991 struct hda_gen_spec *spec = codec->spec; in init_input_src()
5992 struct hda_input_mux *imux = &spec->input_mux; in init_input_src()
5996 if (spec->dyn_adc_switch) in init_input_src()
5999 nums = spec->num_adc_nids; in init_input_src()
6002 for (i = 0; i < imux->num_items; i++) { in init_input_src()
6005 bool active = path->active; in init_input_src()
6006 if (i == spec->cur_mux[c]) in init_input_src()
6011 if (spec->hp_mic) in init_input_src()
6015 if (spec->cap_sync_hook) in init_input_src()
6016 spec->cap_sync_hook(codec, NULL, NULL); in init_input_src()
6022 struct hda_gen_spec *spec = codec->spec; in init_digital()
6026 for (i = 0; i < spec->autocfg.dig_outs; i++) in init_digital()
6027 set_output_and_unmute(codec, spec->digout_paths[i]); in init_digital()
6028 pin = spec->autocfg.dig_in_pin; in init_digital()
6031 resume_path_from_idx(codec, spec->digin_path); in init_digital()
6035 /* clear unsol-event tags on unused pins; Conexant codecs seem to leave
6043 snd_array_for_each(&codec->init_pins, i, pin) { in clear_unsol_on_unused_pins()
6044 hda_nid_t nid = pin->nid; in clear_unsol_on_unused_pins()
6053 * snd_hda_gen_init - initialize the generic spec
6060 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_init()
6062 if (spec->init_hook) in snd_hda_gen_init()
6063 spec->init_hook(codec); in snd_hda_gen_init()
6065 if (!spec->skip_verbs) in snd_hda_gen_init()
6080 /* call init functions of standard auto-mute helpers */ in snd_hda_gen_init()
6085 if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook) in snd_hda_gen_init()
6086 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); in snd_hda_gen_init()
6094 * snd_hda_gen_free - free the generic spec
6102 snd_hda_gen_spec_free(codec->spec); in snd_hda_gen_free()
6103 kfree(codec->spec); in snd_hda_gen_free()
6104 codec->spec = NULL; in snd_hda_gen_free()
6109 * snd_hda_gen_reboot_notify - Make codec enter D3 before rebooting
6119 snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3); in snd_hda_gen_reboot_notify()
6120 snd_hda_codec_write(codec, codec->core.afg, 0, in snd_hda_gen_reboot_notify()
6128 * snd_hda_gen_check_power_status - check the loopback power save state
6136 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_check_power_status()
6137 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); in snd_hda_gen_check_power_status()
6160 * snd_hda_parse_generic_codec - Generic codec parser
6170 return -ENOMEM; in snd_hda_parse_generic_codec()
6172 codec->spec = spec; in snd_hda_parse_generic_codec()
6174 err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0); in snd_hda_parse_generic_codec()
6178 err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg); in snd_hda_parse_generic_codec()
6182 codec->patch_ops = generic_patch_ops; in snd_hda_parse_generic_codec()
6203 MODULE_DESCRIPTION("Generic HD-audio codec parser");