• Home
  • Raw
  • Download

Lines Matching +full:mic +full:- +full:cfg

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()
95 if (spec->led_cdevs[LED_AUDIO_MUTE]) in snd_hda_gen_spec_free()
96 led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MUTE]); in snd_hda_gen_spec_free()
97 if (spec->led_cdevs[LED_AUDIO_MICMUTE]) in snd_hda_gen_spec_free()
98 led_classdev_unregister(spec->led_cdevs[LED_AUDIO_MICMUTE]); in snd_hda_gen_spec_free()
107 struct hda_gen_spec *spec = codec->spec; in parse_user_hints()
112 codec->no_jack_detect = !val; in parse_user_hints()
115 codec->inv_jack_detect = !!val; in parse_user_hints()
118 codec->no_trigger_sense = !val; in parse_user_hints()
121 codec->inv_eapd = !!val; in parse_user_hints()
124 codec->pcm_format_first = !!val; in parse_user_hints()
127 codec->no_sticky_stream = !val; in parse_user_hints()
130 codec->spdif_status_reset = !!val; in parse_user_hints()
133 codec->pin_amp_workaround = !!val; in parse_user_hints()
136 codec->single_adc_amp = !!val; in parse_user_hints()
139 codec->power_save_node = !!val; in parse_user_hints()
143 spec->suppress_auto_mute = !val; in parse_user_hints()
146 spec->suppress_auto_mic = !val; in parse_user_hints()
149 spec->line_in_auto_switch = !!val; in parse_user_hints()
152 spec->auto_mute_via_amp = !!val; in parse_user_hints()
155 spec->need_dac_fix = !!val; in parse_user_hints()
158 spec->no_primary_hp = !val; in parse_user_hints()
161 spec->no_multi_io = !val; in parse_user_hints()
164 spec->multi_cap_vol = !!val; in parse_user_hints()
167 spec->inv_dmic_split = !!val; in parse_user_hints()
170 spec->indep_hp = !!val; in parse_user_hints()
173 spec->add_stereo_mix_input = !!val; in parse_user_hints()
177 spec->add_jack_modes = !!val; in parse_user_hints()
180 spec->add_jack_modes = !!val; in parse_user_hints()
183 spec->add_jack_modes = !!val; in parse_user_hints()
186 spec->power_down_unused = !!val; in parse_user_hints()
189 spec->hp_mic = !!val; in parse_user_hints()
192 spec->suppress_hp_mic_detect = !val; in parse_user_hints()
195 spec->suppress_vmaster = !val; in parse_user_hints()
198 spec->mixer_nid = val; in parse_user_hints()
240 /* return the position of NID in the list, or -1 if not found */
247 return -1; in find_idx_in_nid_list()
253 return find_idx_in_nid_list(nid, path->path, path->depth) >= 0; in is_nid_contained()
260 struct hda_gen_spec *spec = codec->spec; in get_nid_path()
264 snd_array_for_each(&spec->paths, i, path) { in get_nid_path()
265 if (path->depth <= 0) in get_nid_path()
267 if ((!from_nid || path->path[0] == from_nid) && in get_nid_path()
268 (!to_nid || path->path[path->depth - 1] == to_nid)) { in get_nid_path()
279 * snd_hda_get_path_idx - get the index number corresponding to the path
289 struct hda_gen_spec *spec = codec->spec; in snd_hda_get_path_idx()
290 struct nid_path *array = spec->paths.list; in snd_hda_get_path_idx()
293 if (!spec->paths.used) in snd_hda_get_path_idx()
295 idx = path - array; in snd_hda_get_path_idx()
296 if (idx < 0 || idx >= spec->paths.used) in snd_hda_get_path_idx()
303 * snd_hda_get_path_from_idx - get the path instance corresponding to the
310 struct hda_gen_spec *spec = codec->spec; in snd_hda_get_path_from_idx()
312 if (idx <= 0 || idx > spec->paths.used) in snd_hda_get_path_from_idx()
314 return snd_array_elem(&spec->paths, idx - 1); in snd_hda_get_path_from_idx()
321 struct hda_gen_spec *spec = codec->spec; in is_dac_already_used()
325 snd_array_for_each(&spec->paths, i, path) { in is_dac_already_used()
326 if (path->path[0] == nid) in is_dac_already_used()
347 struct hda_gen_spec *spec = codec->spec; in is_ctl_used()
352 snd_array_for_each(&spec->paths, i, path) { in is_ctl_used()
353 if ((path->ctls[type] & AMP_VAL_COMPARE_MASK) == val) in is_ctl_used()
375 for (i = 0; i < path->depth; i++) in print_nid_path()
376 pos += scnprintf(pos, sizeof(buf) - (pos - buf), "%s%02x", in print_nid_path()
378 path->path[i]); in print_nid_path()
380 codec_dbg(codec, "%s path: depth=%d '%s'\n", pfx, path->depth, buf); in print_nid_path()
394 else if (to_nid == (hda_nid_t)(-anchor_nid)) in __parse_nid_path()
427 path->path[path->depth] = conn[i]; in __parse_nid_path()
428 path->idx[path->depth + 1] = i; in __parse_nid_path()
430 path->multi[path->depth + 1] = 1; in __parse_nid_path()
431 path->depth++; in __parse_nid_path()
436 * snd_hda_parse_nid_path - parse the widget path from the given nid to
459 path->path[path->depth] = to_nid; in snd_hda_parse_nid_path()
460 path->depth++; in snd_hda_parse_nid_path()
467 * snd_hda_add_new_path - parse the path between the given NIDs and
480 struct hda_gen_spec *spec = codec->spec; in snd_hda_add_new_path()
491 path = snd_array_new(&spec->paths); in snd_hda_add_new_path()
498 spec->paths.used--; in snd_hda_add_new_path()
515 struct hda_gen_spec *spec = codec->spec; in get_preferred_dac()
516 const hda_nid_t *list = spec->preferred_dacs; in get_preferred_dac()
530 struct hda_gen_spec *spec = codec->spec; in look_for_dac()
534 for (i = 0; i < spec->num_all_dacs; i++) { in look_for_dac()
535 hda_nid_t nid = spec->all_dacs[i]; in look_for_dac()
570 for (i = path->depth - 1; i >= 0; i--) { in look_for_out_mute_nid()
571 if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) in look_for_out_mute_nid()
572 return path->path[i]; in look_for_out_mute_nid()
573 if (i != path->depth - 1 && i != 0 && in look_for_out_mute_nid()
574 nid_has_mute(codec, path->path[i], HDA_INPUT)) in look_for_out_mute_nid()
575 return path->path[i]; in look_for_out_mute_nid()
584 struct hda_gen_spec *spec = codec->spec; in look_for_out_vol_nid()
587 for (i = path->depth - 1; i >= 0; i--) { in look_for_out_vol_nid()
588 hda_nid_t nid = path->path[i]; in look_for_out_vol_nid()
589 if ((spec->out_vol_mask >> nid) & 1) in look_for_out_vol_nid()
601 /* can have the amp-in capability? */
604 hda_nid_t nid = path->path[idx]; in has_amp_in()
615 /* can have the amp-out capability? */
618 hda_nid_t nid = path->path[idx]; in has_amp_out()
633 struct hda_gen_spec *spec = codec->spec; in is_active_nid()
638 if (nid == codec->core.afg) in is_active_nid()
641 snd_array_for_each(&spec->paths, n, path) { in is_active_nid()
642 if (!path->active) in is_active_nid()
644 if (codec->power_save_node) { in is_active_nid()
645 if (!path->stream_enabled) in is_active_nid()
648 if (!(path->pin_enabled || path->pin_fixed) && in is_active_nid()
652 for (i = 0; i < path->depth; i++) { in is_active_nid()
653 if (path->path[i] == nid) { in is_active_nid()
654 if (dir == HDA_OUTPUT || idx == -1 || in is_active_nid()
655 path->idx[i] == idx) in is_active_nid()
666 is_active_nid(codec, nid, HDA_OUTPUT, -1)
686 /* is this a stereo widget or a stereo-to-mono mix? */
777 hda_nid_t nid = path->path[i]; in activate_amp_out()
785 struct hda_gen_spec *spec = codec->spec; in activate_amp_in()
789 hda_nid_t nid = path->path[i]; in activate_amp_in()
796 (type == AC_WID_AUD_IN && codec->single_adc_amp)) { in activate_amp_in()
800 idx = path->idx[i]; in activate_amp_in()
806 * when aa-mixer is available, we need to enable the path as well in activate_amp_in()
810 if (conn[n] != spec->mixer_merge_nid) in activate_amp_in()
830 for (i = 0; i < path->depth; i++) { in path_power_update()
831 nid = path->path[i]; in path_power_update()
834 if (nid == codec->core.afg) in path_power_update()
854 snd_hdac_regmap_sync_node(&codec->core, nid); in path_power_update()
871 * snd_hda_activate_path - activate or deactivate the given path
877 * If @add_aamix is set, enable the input from aa-mix NID as well (if any).
882 struct hda_gen_spec *spec = codec->spec; in snd_hda_activate_path()
885 path->active = enable; in snd_hda_activate_path()
888 if (enable && (spec->power_down_unused || codec->power_save_node)) in snd_hda_activate_path()
889 path_power_update(codec, path, codec->power_save_node); in snd_hda_activate_path()
891 for (i = path->depth - 1; i >= 0; i--) { in snd_hda_activate_path()
892 hda_nid_t nid = path->path[i]; in snd_hda_activate_path()
894 if (enable && path->multi[i]) in snd_hda_activate_path()
897 path->idx[i]); in snd_hda_activate_path()
909 struct hda_gen_spec *spec = codec->spec; in path_power_down_sync()
911 if (!(spec->power_down_unused || codec->power_save_node) || path->active) in path_power_down_sync()
919 struct hda_gen_spec *spec = codec->spec; in set_pin_eapd()
920 if (spec->own_eapd_ctl || in set_pin_eapd()
923 if (spec->keep_eapd_on && !enable) in set_pin_eapd()
925 if (codec->inv_eapd) in set_pin_eapd()
932 /* re-initialize the path specified by the given path index */
937 snd_hda_activate_path(codec, path, path->active, false); in resume_path_from_idx()
987 knew->index = cidx; in add_control()
989 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in add_control()
990 knew->private_value = val; in add_control()
1001 return -ENOMEM; in add_control_with_pfx()
1020 val = path->ctls[NID_PATH_VOL_CTL]; in add_vol_ctl()
1024 return __add_pb_vol_ctrl(codec->spec, HDA_CTL_WIDGET_VOL, pfx, cidx, val); in add_vol_ctl()
1027 /* return the channel bits suitable for the given path->ctls[] */
1033 hda_nid_t nid = get_amp_nid_(path->ctls[type]); in get_default_ch_nums()
1047 /* create a mute-switch for the given mixer widget;
1048 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
1058 val = path->ctls[NID_PATH_MUTE_CTL]; in add_sw_ctl()
1070 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); in add_sw_ctl()
1085 struct hda_gen_spec *spec = codec->spec; in sync_auto_mute_bits()
1087 if (spec->auto_mute_via_amp) { in sync_auto_mute_bits()
1089 bool enabled = !((spec->mute_bits >> nid) & 1); in sync_auto_mute_bits()
1090 ucontrol->value.integer.value[0] &= enabled; in sync_auto_mute_bits()
1091 ucontrol->value.integer.value[1] &= enabled; in sync_auto_mute_bits()
1115 mutex_lock(&codec->control_mutex); in hda_gen_bind_mute_get()
1116 pval = kcontrol->private_value; in hda_gen_bind_mute_get()
1117 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ in hda_gen_bind_mute_get()
1119 kcontrol->private_value = pval; in hda_gen_bind_mute_get()
1120 mutex_unlock(&codec->control_mutex); in hda_gen_bind_mute_get()
1133 mutex_lock(&codec->control_mutex); in hda_gen_bind_mute_put()
1134 pval = kcontrol->private_value; in hda_gen_bind_mute_put()
1137 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | in hda_gen_bind_mute_put()
1144 kcontrol->private_value = pval; in hda_gen_bind_mute_put()
1145 mutex_unlock(&codec->control_mutex); in hda_gen_bind_mute_put()
1153 return path && path->ctls[ctl_type]; in path_has_mixer()
1164 struct hda_gen_spec *spec = codec->spec; in get_line_out_pfx()
1165 struct auto_pin_cfg *cfg = &spec->autocfg; in get_line_out_pfx() local
1168 if (cfg->line_outs == 1 && !spec->multi_ios && in get_line_out_pfx()
1169 !codec->force_pin_prefix && in get_line_out_pfx()
1170 !cfg->hp_outs && !cfg->speaker_outs) in get_line_out_pfx()
1171 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1176 if (spec->multiout.num_dacs == 1 && !spec->mixer_nid && in get_line_out_pfx()
1177 !codec->force_pin_prefix && in get_line_out_pfx()
1178 !spec->multiout.hp_out_nid[0] && !spec->multiout.extra_out_nid[0]) in get_line_out_pfx()
1179 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1181 /* multi-io channels */ in get_line_out_pfx()
1182 if (ch >= cfg->line_outs) in get_line_out_pfx()
1185 switch (cfg->line_out_type) { in get_line_out_pfx()
1190 if (!ch && cfg->hp_outs && in get_line_out_pfx()
1191 !path_has_mixer(codec, spec->hp_paths[0], ctl_type)) in get_line_out_pfx()
1193 if (cfg->line_outs == 1) in get_line_out_pfx()
1195 if (cfg->line_outs == 2) in get_line_out_pfx()
1202 if (!ch && cfg->speaker_outs && in get_line_out_pfx()
1203 !path_has_mixer(codec, spec->speaker_paths[0], ctl_type)) in get_line_out_pfx()
1205 /* for multi-io case, only the primary out */ in get_line_out_pfx()
1206 if (ch && spec->multi_ios) in get_line_out_pfx()
1217 if (cfg->speaker_outs) in get_line_out_pfx()
1219 spec->speaker_paths[0], ctl_type); in get_line_out_pfx()
1220 if (cfg->hp_outs) in get_line_out_pfx()
1221 hp_lo_shared = !path_has_mixer(codec, spec->hp_paths[0], ctl_type); in get_line_out_pfx()
1223 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1232 if (cfg->line_outs == 1 && !spec->multi_ios) in get_line_out_pfx()
1254 /* No possible multi-ios */
1281 struct hda_gen_spec *spec = codec->spec; in assign_out_path_ctls()
1289 if (path->ctls[NID_PATH_VOL_CTL] || in assign_out_path_ctls()
1290 path->ctls[NID_PATH_MUTE_CTL]) in assign_out_path_ctls()
1296 if (spec->dac_min_mute) in assign_out_path_ctls()
1301 path->ctls[NID_PATH_VOL_CTL] = val; in assign_out_path_ctls()
1315 path->ctls[NID_PATH_MUTE_CTL] = val; in assign_out_path_ctls()
1344 struct hda_gen_spec *spec = codec->spec; in get_primary_out()
1345 struct auto_pin_cfg *cfg = &spec->autocfg; in get_primary_out() local
1347 if (cfg->line_outs > idx) in get_primary_out()
1348 return spec->private_dac_nids[idx]; in get_primary_out()
1349 idx -= cfg->line_outs; in get_primary_out()
1350 if (spec->multi_ios > idx) in get_primary_out()
1351 return spec->multi_io[idx].dac; in get_primary_out()
1368 struct hda_gen_spec *spec = codec->spec; in try_assign_dacs()
1380 if (!spec->obey_preferred_dacs) { in try_assign_dacs()
1391 badness += bad->shared_primary; in try_assign_dacs()
1392 } else if (spec->obey_preferred_dacs) { in try_assign_dacs()
1420 badness += bad->shared_primary; in try_assign_dacs()
1422 badness += bad->shared_surr; in try_assign_dacs()
1424 badness += bad->shared_clfe; in try_assign_dacs()
1425 } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { in try_assign_dacs()
1426 dac = spec->private_dac_nids[0]; in try_assign_dacs()
1427 badness += bad->shared_surr_main; in try_assign_dacs()
1429 badness += bad->no_primary_dac; in try_assign_dacs()
1431 badness += bad->no_dac; in try_assign_dacs()
1435 path = snd_hda_add_new_path(codec, dac, pin, -spec->mixer_nid); in try_assign_dacs()
1436 if (!path && !i && spec->mixer_nid) { in try_assign_dacs()
1442 badness += bad->no_dac; in try_assign_dacs()
1445 path->active = true; in try_assign_dacs()
1457 struct hda_gen_spec *spec = codec->spec; in get_dac_if_single()
1461 for (i = 0; i < spec->num_all_dacs; i++) { in get_dac_if_single()
1462 hda_nid_t nid = spec->all_dacs[i]; in get_dac_if_single()
1474 /* check whether the given pin can be a multi-io pin */
1491 /* count the number of input pins that are capable to be multi-io */
1494 struct hda_gen_spec *spec = codec->spec; in count_multiio_pins()
1495 struct auto_pin_cfg *cfg = &spec->autocfg; in count_multiio_pins() local
1501 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { in count_multiio_pins()
1502 for (i = 0; i < cfg->num_inputs; i++) { in count_multiio_pins()
1503 if (cfg->inputs[i].type != type) in count_multiio_pins()
1506 cfg->inputs[i].pin)) in count_multiio_pins()
1514 * multi-io helper
1517 * zero if any pins are filled, non-zero if nothing found.
1525 struct hda_gen_spec *spec = codec->spec; in fill_multi_ios()
1526 struct auto_pin_cfg *cfg = &spec->autocfg; in fill_multi_ios() local
1533 old_pins = spec->multi_ios; in fill_multi_ios()
1541 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { in fill_multi_ios()
1542 for (i = 0; i < cfg->num_inputs; i++) { in fill_multi_ios()
1543 hda_nid_t nid = cfg->inputs[i].pin; in fill_multi_ios()
1546 if (cfg->inputs[i].type != type) in fill_multi_ios()
1550 for (j = 0; j < spec->multi_ios; j++) { in fill_multi_ios()
1551 if (nid == spec->multi_io[j].pin) in fill_multi_ios()
1554 if (j < spec->multi_ios) in fill_multi_ios()
1566 -spec->mixer_nid); in fill_multi_ios()
1572 spec->multi_io[spec->multi_ios].pin = nid; in fill_multi_ios()
1573 spec->multi_io[spec->multi_ios].dac = dac; in fill_multi_ios()
1574 spec->out_paths[cfg->line_outs + spec->multi_ios] = in fill_multi_ios()
1576 spec->multi_ios++; in fill_multi_ios()
1577 if (spec->multi_ios >= 2) in fill_multi_ios()
1584 if (old_pins == spec->multi_ios) { in fill_multi_ios()
1590 if (!hardwired && spec->multi_ios < 2) { in fill_multi_ios()
1592 spec->paths.used -= spec->multi_ios - old_pins; in fill_multi_ios()
1593 spec->multi_ios = old_pins; in fill_multi_ios()
1598 for (i = old_pins; i < spec->multi_ios; i++) { in fill_multi_ios()
1599 path = snd_hda_get_path_from_idx(codec, spec->out_paths[cfg->line_outs + i]); in fill_multi_ios()
1610 struct hda_gen_spec *spec = codec->spec; in map_singles()
1622 -spec->mixer_nid); in map_singles()
1623 if (!path && !i && spec->mixer_nid) in map_singles()
1629 path->active = true; in map_singles()
1638 return spec->aamix_out_paths[0] || spec->aamix_out_paths[1] || in has_aamix_out_paths()
1639 spec->aamix_out_paths[2]; in has_aamix_out_paths()
1645 struct hda_gen_spec *spec = codec->spec; in check_aamix_out_path()
1650 if (!path || !path->depth || in check_aamix_out_path()
1651 is_nid_contained(path, spec->mixer_nid)) in check_aamix_out_path()
1653 path_dac = path->path[0]; in check_aamix_out_path()
1654 dac = spec->private_dac_nids[0]; in check_aamix_out_path()
1655 pin = path->path[path->depth - 1]; in check_aamix_out_path()
1656 path = snd_hda_add_new_path(codec, dac, pin, spec->mixer_nid); in check_aamix_out_path()
1660 else if (spec->multiout.hp_out_nid[0]) in check_aamix_out_path()
1661 dac = spec->multiout.hp_out_nid[0]; in check_aamix_out_path()
1662 else if (spec->multiout.extra_out_nid[0]) in check_aamix_out_path()
1663 dac = spec->multiout.extra_out_nid[0]; in check_aamix_out_path()
1668 spec->mixer_nid); in check_aamix_out_path()
1672 /* print_nid_path(codec, "output-aamix", path); */ in check_aamix_out_path()
1673 path->active = false; /* unused as default */ in check_aamix_out_path()
1674 path->pin_fixed = true; /* static route */ in check_aamix_out_path()
1681 struct hda_gen_spec *spec = codec->spec; in indep_hp_possible()
1682 struct auto_pin_cfg *cfg = &spec->autocfg; in indep_hp_possible() local
1686 if (cfg->line_out_type == AUTO_PIN_HP_OUT) in indep_hp_possible()
1687 idx = spec->out_paths[0]; in indep_hp_possible()
1689 idx = spec->hp_paths[0]; in indep_hp_possible()
1695 if (!spec->mixer_nid || !is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1699 for (i = 0; i < cfg->line_outs; i++) { in indep_hp_possible()
1700 if (spec->out_paths[i] == idx) in indep_hp_possible()
1702 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); in indep_hp_possible()
1703 if (path && is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1706 for (i = 0; i < cfg->speaker_outs; i++) { in indep_hp_possible()
1707 path = snd_hda_get_path_from_idx(codec, spec->speaker_paths[i]); in indep_hp_possible()
1708 if (path && is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1730 dacs[i] = path->path[0]; in refill_shared_dacs()
1739 struct hda_gen_spec *spec = codec->spec; in fill_and_eval_dacs()
1740 struct auto_pin_cfg *cfg = &spec->autocfg; in fill_and_eval_dacs() local
1744 spec->multiout.num_dacs = cfg->line_outs; in fill_and_eval_dacs()
1745 spec->multiout.dac_nids = spec->private_dac_nids; in fill_and_eval_dacs()
1746 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); in fill_and_eval_dacs()
1747 memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); in fill_and_eval_dacs()
1748 memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid)); in fill_and_eval_dacs()
1749 spec->multi_ios = 0; in fill_and_eval_dacs()
1750 snd_array_free(&spec->paths); in fill_and_eval_dacs()
1753 memset(spec->out_paths, 0, sizeof(spec->out_paths)); in fill_and_eval_dacs()
1754 memset(spec->hp_paths, 0, sizeof(spec->hp_paths)); in fill_and_eval_dacs()
1755 memset(spec->speaker_paths, 0, sizeof(spec->speaker_paths)); in fill_and_eval_dacs()
1756 memset(spec->aamix_out_paths, 0, sizeof(spec->aamix_out_paths)); in fill_and_eval_dacs()
1757 memset(spec->digout_paths, 0, sizeof(spec->digout_paths)); in fill_and_eval_dacs()
1758 memset(spec->input_paths, 0, sizeof(spec->input_paths)); in fill_and_eval_dacs()
1759 memset(spec->loopback_paths, 0, sizeof(spec->loopback_paths)); in fill_and_eval_dacs()
1760 memset(&spec->digin_path, 0, sizeof(spec->digin_path)); in fill_and_eval_dacs()
1764 /* fill hard-wired DACs first */ in fill_and_eval_dacs()
1768 mapped = map_singles(codec, cfg->line_outs, in fill_and_eval_dacs()
1769 cfg->line_out_pins, in fill_and_eval_dacs()
1770 spec->private_dac_nids, in fill_and_eval_dacs()
1771 spec->out_paths); in fill_and_eval_dacs()
1772 mapped |= map_singles(codec, cfg->hp_outs, in fill_and_eval_dacs()
1773 cfg->hp_pins, in fill_and_eval_dacs()
1774 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1775 spec->hp_paths); in fill_and_eval_dacs()
1776 mapped |= map_singles(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1777 cfg->speaker_pins, in fill_and_eval_dacs()
1778 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1779 spec->speaker_paths); in fill_and_eval_dacs()
1780 if (!spec->no_multi_io && in fill_and_eval_dacs()
1781 fill_mio_first && cfg->line_outs == 1 && in fill_and_eval_dacs()
1782 cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1783 err = fill_multi_ios(codec, cfg->line_out_pins[0], true); in fill_and_eval_dacs()
1790 badness += try_assign_dacs(codec, cfg->line_outs, cfg->line_out_pins, in fill_and_eval_dacs()
1791 spec->private_dac_nids, spec->out_paths, in fill_and_eval_dacs()
1792 spec->main_out_badness); in fill_and_eval_dacs()
1794 if (!spec->no_multi_io && fill_mio_first && in fill_and_eval_dacs()
1795 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1796 /* try to fill multi-io first */ in fill_and_eval_dacs()
1797 err = fill_multi_ios(codec, cfg->line_out_pins[0], false); in fill_and_eval_dacs()
1803 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in fill_and_eval_dacs()
1804 err = try_assign_dacs(codec, cfg->hp_outs, cfg->hp_pins, in fill_and_eval_dacs()
1805 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1806 spec->hp_paths, in fill_and_eval_dacs()
1807 spec->extra_out_badness); in fill_and_eval_dacs()
1812 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1813 err = try_assign_dacs(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1814 cfg->speaker_pins, in fill_and_eval_dacs()
1815 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1816 spec->speaker_paths, in fill_and_eval_dacs()
1817 spec->extra_out_badness); in fill_and_eval_dacs()
1822 if (!spec->no_multi_io && in fill_and_eval_dacs()
1823 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1824 err = fill_multi_ios(codec, cfg->line_out_pins[0], false); in fill_and_eval_dacs()
1830 if (spec->mixer_nid) { in fill_and_eval_dacs()
1831 spec->aamix_out_paths[0] = in fill_and_eval_dacs()
1832 check_aamix_out_path(codec, spec->out_paths[0]); in fill_and_eval_dacs()
1833 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in fill_and_eval_dacs()
1834 spec->aamix_out_paths[1] = in fill_and_eval_dacs()
1835 check_aamix_out_path(codec, spec->hp_paths[0]); in fill_and_eval_dacs()
1836 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1837 spec->aamix_out_paths[2] = in fill_and_eval_dacs()
1838 check_aamix_out_path(codec, spec->speaker_paths[0]); in fill_and_eval_dacs()
1841 if (!spec->no_multi_io && in fill_and_eval_dacs()
1842 cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1843 if (count_multiio_pins(codec, cfg->hp_pins[0]) >= 2) in fill_and_eval_dacs()
1844 spec->multi_ios = 1; /* give badness */ in fill_and_eval_dacs()
1846 /* re-count num_dacs and squash invalid entries */ in fill_and_eval_dacs()
1847 spec->multiout.num_dacs = 0; in fill_and_eval_dacs()
1848 for (i = 0; i < cfg->line_outs; i++) { in fill_and_eval_dacs()
1849 if (spec->private_dac_nids[i]) in fill_and_eval_dacs()
1850 spec->multiout.num_dacs++; in fill_and_eval_dacs()
1852 memmove(spec->private_dac_nids + i, in fill_and_eval_dacs()
1853 spec->private_dac_nids + i + 1, in fill_and_eval_dacs()
1854 sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); in fill_and_eval_dacs()
1855 spec->private_dac_nids[cfg->line_outs - 1] = 0; in fill_and_eval_dacs()
1859 spec->ext_channel_count = spec->min_channel_count = in fill_and_eval_dacs()
1860 spec->multiout.num_dacs * 2; in fill_and_eval_dacs()
1862 if (spec->multi_ios == 2) { in fill_and_eval_dacs()
1864 spec->private_dac_nids[spec->multiout.num_dacs++] = in fill_and_eval_dacs()
1865 spec->multi_io[i].dac; in fill_and_eval_dacs()
1866 } else if (spec->multi_ios) { in fill_and_eval_dacs()
1867 spec->multi_ios = 0; in fill_and_eval_dacs()
1871 if (spec->indep_hp && !indep_hp_possible(codec)) in fill_and_eval_dacs()
1874 /* re-fill the shared DAC for speaker / headphone */ in fill_and_eval_dacs()
1875 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in fill_and_eval_dacs()
1876 refill_shared_dacs(codec, cfg->hp_outs, in fill_and_eval_dacs()
1877 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1878 spec->hp_paths); in fill_and_eval_dacs()
1879 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1880 refill_shared_dacs(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1881 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1882 spec->speaker_paths); in fill_and_eval_dacs()
1909 struct auto_pin_cfg *cfg) in debug_show_configs() argument
1911 struct hda_gen_spec *spec = codec->spec; in debug_show_configs()
1916 cfg->line_out_pins[0], cfg->line_out_pins[1], in debug_show_configs()
1917 cfg->line_out_pins[2], cfg->line_out_pins[3], in debug_show_configs()
1918 spec->multiout.dac_nids[0], in debug_show_configs()
1919 spec->multiout.dac_nids[1], in debug_show_configs()
1920 spec->multiout.dac_nids[2], in debug_show_configs()
1921 spec->multiout.dac_nids[3], in debug_show_configs()
1922 lo_type[cfg->line_out_type]); in debug_show_configs()
1923 for (i = 0; i < cfg->line_outs; i++) in debug_show_configs()
1924 print_nid_path_idx(codec, " out", spec->out_paths[i]); in debug_show_configs()
1925 if (spec->multi_ios > 0) in debug_show_configs()
1927 spec->multi_ios, in debug_show_configs()
1928 spec->multi_io[0].pin, spec->multi_io[1].pin, in debug_show_configs()
1929 spec->multi_io[0].dac, spec->multi_io[1].dac); in debug_show_configs()
1930 for (i = 0; i < spec->multi_ios; i++) in debug_show_configs()
1932 spec->out_paths[cfg->line_outs + i]); in debug_show_configs()
1933 if (cfg->hp_outs) in debug_show_configs()
1935 cfg->hp_pins[0], cfg->hp_pins[1], in debug_show_configs()
1936 cfg->hp_pins[2], cfg->hp_pins[3], in debug_show_configs()
1937 spec->multiout.hp_out_nid[0], in debug_show_configs()
1938 spec->multiout.hp_out_nid[1], in debug_show_configs()
1939 spec->multiout.hp_out_nid[2], in debug_show_configs()
1940 spec->multiout.hp_out_nid[3]); in debug_show_configs()
1941 for (i = 0; i < cfg->hp_outs; i++) in debug_show_configs()
1942 print_nid_path_idx(codec, " hp ", spec->hp_paths[i]); in debug_show_configs()
1943 if (cfg->speaker_outs) in debug_show_configs()
1945 cfg->speaker_pins[0], cfg->speaker_pins[1], in debug_show_configs()
1946 cfg->speaker_pins[2], cfg->speaker_pins[3], in debug_show_configs()
1947 spec->multiout.extra_out_nid[0], in debug_show_configs()
1948 spec->multiout.extra_out_nid[1], in debug_show_configs()
1949 spec->multiout.extra_out_nid[2], in debug_show_configs()
1950 spec->multiout.extra_out_nid[3]); in debug_show_configs()
1951 for (i = 0; i < cfg->speaker_outs; i++) in debug_show_configs()
1952 print_nid_path_idx(codec, " spk", spec->speaker_paths[i]); in debug_show_configs()
1954 print_nid_path_idx(codec, " mix", spec->aamix_out_paths[i]); in debug_show_configs()
1957 #define debug_show_configs(codec, cfg) /* NOP */ argument
1963 struct hda_gen_spec *spec = codec->spec; in fill_all_dac_nids()
1966 spec->num_all_dacs = 0; in fill_all_dac_nids()
1967 memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); in fill_all_dac_nids()
1971 if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { in fill_all_dac_nids()
1975 spec->all_dacs[spec->num_all_dacs++] = nid; in fill_all_dac_nids()
1981 struct hda_gen_spec *spec = codec->spec; in parse_output_paths()
1982 struct auto_pin_cfg *cfg = &spec->autocfg; in parse_output_paths() local
1993 return -ENOMEM; in parse_output_paths()
1994 *best_cfg = *cfg; in parse_output_paths()
2004 cfg->line_out_type, fill_hardwired, fill_mio_first, in parse_output_paths()
2006 debug_show_configs(codec, cfg); in parse_output_paths()
2009 *best_cfg = *cfg; in parse_output_paths()
2024 if (cfg->speaker_outs > 0 && in parse_output_paths()
2025 cfg->line_out_type == AUTO_PIN_HP_OUT) { in parse_output_paths()
2026 cfg->hp_outs = cfg->line_outs; in parse_output_paths()
2027 memcpy(cfg->hp_pins, cfg->line_out_pins, in parse_output_paths()
2028 sizeof(cfg->hp_pins)); in parse_output_paths()
2029 cfg->line_outs = cfg->speaker_outs; in parse_output_paths()
2030 memcpy(cfg->line_out_pins, cfg->speaker_pins, in parse_output_paths()
2031 sizeof(cfg->speaker_pins)); in parse_output_paths()
2032 cfg->speaker_outs = 0; in parse_output_paths()
2033 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); in parse_output_paths()
2034 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; in parse_output_paths()
2038 if (cfg->hp_outs > 0 && in parse_output_paths()
2039 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { in parse_output_paths()
2040 cfg->speaker_outs = cfg->line_outs; in parse_output_paths()
2041 memcpy(cfg->speaker_pins, cfg->line_out_pins, in parse_output_paths()
2042 sizeof(cfg->speaker_pins)); in parse_output_paths()
2043 cfg->line_outs = cfg->hp_outs; in parse_output_paths()
2044 memcpy(cfg->line_out_pins, cfg->hp_pins, in parse_output_paths()
2045 sizeof(cfg->hp_pins)); in parse_output_paths()
2046 cfg->hp_outs = 0; in parse_output_paths()
2047 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); in parse_output_paths()
2048 cfg->line_out_type = AUTO_PIN_HP_OUT; in parse_output_paths()
2057 *cfg = *best_cfg; in parse_output_paths()
2061 cfg->line_out_type, best_wired, best_mio); in parse_output_paths()
2062 debug_show_configs(codec, cfg); in parse_output_paths()
2064 if (cfg->line_out_pins[0]) { in parse_output_paths()
2066 path = snd_hda_get_path_from_idx(codec, spec->out_paths[0]); in parse_output_paths()
2068 spec->vmaster_nid = look_for_out_vol_nid(codec, path); in parse_output_paths()
2069 if (spec->vmaster_nid) { in parse_output_paths()
2070 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, in parse_output_paths()
2071 HDA_OUTPUT, spec->vmaster_tlv); in parse_output_paths()
2072 if (spec->dac_min_mute) in parse_output_paths()
2073 spec->vmaster_tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] |= TLV_DB_SCALE_MUTE; in parse_output_paths()
2078 if (spec->prefer_hp_amp || cfg->line_out_type == AUTO_PIN_HP_OUT) in parse_output_paths()
2082 set_pin_targets(codec, cfg->line_outs, cfg->line_out_pins, val); in parse_output_paths()
2083 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in parse_output_paths()
2084 set_pin_targets(codec, cfg->hp_outs, cfg->hp_pins, PIN_HP); in parse_output_paths()
2085 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in parse_output_paths()
2086 val = spec->prefer_hp_amp ? PIN_HP : PIN_OUT; in parse_output_paths()
2087 set_pin_targets(codec, cfg->speaker_outs, in parse_output_paths()
2088 cfg->speaker_pins, val); in parse_output_paths()
2092 if (spec->indep_hp && !indep_hp_possible(codec)) in parse_output_paths()
2093 spec->indep_hp = 0; in parse_output_paths()
2101 const struct auto_pin_cfg *cfg) in create_multi_out_ctls() argument
2103 struct hda_gen_spec *spec = codec->spec; in create_multi_out_ctls()
2106 noutputs = cfg->line_outs; in create_multi_out_ctls()
2107 if (spec->multi_ios > 0 && cfg->line_outs < 3) in create_multi_out_ctls()
2108 noutputs += spec->multi_ios; in create_multi_out_ctls()
2115 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); in create_multi_out_ctls()
2199 struct hda_gen_spec *spec = codec->spec; in create_hp_out_ctls()
2200 return create_extra_outs(codec, spec->autocfg.hp_outs, in create_hp_out_ctls()
2201 spec->hp_paths, in create_hp_out_ctls()
2207 struct hda_gen_spec *spec = codec->spec; in create_speaker_out_ctls()
2208 return create_extra_outs(codec, spec->autocfg.speaker_outs, in create_speaker_out_ctls()
2209 spec->speaker_paths, in create_speaker_out_ctls()
2229 struct hda_gen_spec *spec = codec->spec; in indep_hp_get()
2230 ucontrol->value.enumerated.item[0] = spec->indep_hp_enabled; in indep_hp_get()
2242 struct hda_gen_spec *spec = codec->spec; in indep_hp_put()
2243 unsigned int select = ucontrol->value.enumerated.item[0]; in indep_hp_put()
2246 mutex_lock(&spec->pcm_mutex); in indep_hp_put()
2247 if (spec->active_streams) { in indep_hp_put()
2248 ret = -EBUSY; in indep_hp_put()
2252 if (spec->indep_hp_enabled != select) { in indep_hp_put()
2254 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in indep_hp_put()
2255 dacp = &spec->private_dac_nids[0]; in indep_hp_put()
2257 dacp = &spec->multiout.hp_out_nid[0]; in indep_hp_put()
2260 if (spec->have_aamix_ctl) { in indep_hp_put()
2261 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in indep_hp_put()
2262 update_aamix_paths(codec, spec->aamix_mode, in indep_hp_put()
2263 spec->out_paths[0], in indep_hp_put()
2264 spec->aamix_out_paths[0], in indep_hp_put()
2265 spec->autocfg.line_out_type); in indep_hp_put()
2267 update_aamix_paths(codec, spec->aamix_mode, in indep_hp_put()
2268 spec->hp_paths[0], in indep_hp_put()
2269 spec->aamix_out_paths[1], in indep_hp_put()
2273 spec->indep_hp_enabled = select; in indep_hp_put()
2274 if (spec->indep_hp_enabled) in indep_hp_put()
2277 *dacp = spec->alt_dac_nid; in indep_hp_put()
2283 mutex_unlock(&spec->pcm_mutex); in indep_hp_put()
2298 struct hda_gen_spec *spec = codec->spec; in create_indep_hp_ctls()
2301 if (!spec->indep_hp) in create_indep_hp_ctls()
2303 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in create_indep_hp_ctls()
2304 dac = spec->multiout.dac_nids[0]; in create_indep_hp_ctls()
2306 dac = spec->multiout.hp_out_nid[0]; in create_indep_hp_ctls()
2308 spec->indep_hp = 0; in create_indep_hp_ctls()
2312 spec->indep_hp_enabled = false; in create_indep_hp_ctls()
2313 spec->alt_dac_nid = dac; in create_indep_hp_ctls()
2315 return -ENOMEM; in create_indep_hp_ctls()
2327 struct hda_gen_spec *spec = codec->spec; in ch_mode_info()
2330 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ch_mode_info()
2331 uinfo->count = 1; in ch_mode_info()
2332 uinfo->value.enumerated.items = spec->multi_ios + 1; in ch_mode_info()
2333 if (uinfo->value.enumerated.item > spec->multi_ios) in ch_mode_info()
2334 uinfo->value.enumerated.item = spec->multi_ios; in ch_mode_info()
2335 chs = uinfo->value.enumerated.item * 2 + spec->min_channel_count; in ch_mode_info()
2336 sprintf(uinfo->value.enumerated.name, "%dch", chs); in ch_mode_info()
2344 struct hda_gen_spec *spec = codec->spec; in ch_mode_get()
2345 ucontrol->value.enumerated.item[0] = in ch_mode_get()
2346 (spec->ext_channel_count - spec->min_channel_count) / 2; in ch_mode_get()
2353 struct hda_gen_spec *spec = codec->spec; in get_multiio_path()
2355 spec->out_paths[spec->autocfg.line_outs + idx]); in get_multiio_path()
2365 return !spec->have_aamix_ctl || spec->aamix_mode; in aamix_default()
2370 struct hda_gen_spec *spec = codec->spec; in set_multi_io()
2371 hda_nid_t nid = spec->multi_io[idx].pin; in set_multi_io()
2376 return -EINVAL; in set_multi_io()
2378 if (path->active == output) in set_multi_io()
2388 set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true); in set_multi_io()
2402 struct hda_gen_spec *spec = codec->spec; in ch_mode_put()
2405 ch = ucontrol->value.enumerated.item[0]; in ch_mode_put()
2406 if (ch < 0 || ch > spec->multi_ios) in ch_mode_put()
2407 return -EINVAL; in ch_mode_put()
2408 if (ch == (spec->ext_channel_count - spec->min_channel_count) / 2) in ch_mode_put()
2410 spec->ext_channel_count = ch * 2 + spec->min_channel_count; in ch_mode_put()
2411 for (i = 0; i < spec->multi_ios; i++) in ch_mode_put()
2413 spec->multiout.max_channels = max(spec->ext_channel_count, in ch_mode_put()
2414 spec->const_channel_count); in ch_mode_put()
2415 if (spec->need_dac_fix) in ch_mode_put()
2416 spec->multiout.num_dacs = spec->multiout.max_channels / 2; in ch_mode_put()
2430 struct hda_gen_spec *spec = codec->spec; in create_multi_channel_mode()
2432 if (spec->multi_ios > 0) { in create_multi_channel_mode()
2434 return -ENOMEM; in create_multi_channel_mode()
2449 struct hda_gen_spec *spec = codec->spec; in loopback_mixing_get()
2450 ucontrol->value.enumerated.item[0] = spec->aamix_mode; in loopback_mixing_get()
2458 struct hda_gen_spec *spec = codec->spec; in update_aamix_paths()
2469 if (out_type == AUTO_PIN_HP_OUT && spec->indep_hp_enabled && in update_aamix_paths()
2470 mix_path->path[0] != spec->alt_dac_nid) in update_aamix_paths()
2484 /* re-initialize the output paths; only called from loopback_mixing_put() */
2488 struct hda_gen_spec *spec = codec->spec; in update_output_paths()
2495 snd_hda_activate_path(codec, path, path->active, in update_output_paths()
2496 spec->aamix_mode); in update_output_paths()
2504 struct hda_gen_spec *spec = codec->spec; in loopback_mixing_put()
2505 const struct auto_pin_cfg *cfg = &spec->autocfg; in loopback_mixing_put() local
2506 unsigned int val = ucontrol->value.enumerated.item[0]; in loopback_mixing_put()
2508 if (val == spec->aamix_mode) in loopback_mixing_put()
2510 spec->aamix_mode = val; in loopback_mixing_put()
2512 update_aamix_paths(codec, val, spec->out_paths[0], in loopback_mixing_put()
2513 spec->aamix_out_paths[0], in loopback_mixing_put()
2514 cfg->line_out_type); in loopback_mixing_put()
2515 update_aamix_paths(codec, val, spec->hp_paths[0], in loopback_mixing_put()
2516 spec->aamix_out_paths[1], in loopback_mixing_put()
2518 update_aamix_paths(codec, val, spec->speaker_paths[0], in loopback_mixing_put()
2519 spec->aamix_out_paths[2], in loopback_mixing_put()
2522 update_output_paths(codec, cfg->line_outs, spec->out_paths); in loopback_mixing_put()
2523 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in loopback_mixing_put()
2524 update_output_paths(codec, cfg->hp_outs, spec->hp_paths); in loopback_mixing_put()
2525 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in loopback_mixing_put()
2526 update_output_paths(codec, cfg->speaker_outs, in loopback_mixing_put()
2527 spec->speaker_paths); in loopback_mixing_put()
2542 struct hda_gen_spec *spec = codec->spec; in create_loopback_mixing_ctl()
2544 if (!spec->mixer_nid) in create_loopback_mixing_ctl()
2547 return -ENOMEM; in create_loopback_mixing_ctl()
2548 spec->have_aamix_ctl = 1; in create_loopback_mixing_ctl()
2553 * shared headphone/mic handling
2558 /* for shared I/O, change the pin-control accordingly */
2561 struct hda_gen_spec *spec = codec->spec; in update_hp_mic()
2566 pin = spec->hp_mic_pin; in update_hp_mic()
2567 as_mic = spec->cur_mux[adc_mux] == spec->hp_mic_mux_idx; in update_hp_mic()
2584 if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { in update_hp_mic()
2585 const hda_nid_t vref_pin = spec->shared_mic_vref_pin; in update_hp_mic()
2592 if (!spec->hp_mic_jack_modes) { in update_hp_mic()
2605 struct hda_gen_spec *spec = codec->spec; in create_hp_mic()
2606 struct auto_pin_cfg *cfg = &spec->autocfg; in create_hp_mic() local
2610 if (!spec->hp_mic) { in create_hp_mic()
2611 if (spec->suppress_hp_mic_detect) in create_hp_mic()
2614 * input pin is found, try to detect the shared hp/mic in create_hp_mic()
2616 if (cfg->num_inputs > 1) in create_hp_mic()
2618 else if (cfg->num_inputs == 1) { in create_hp_mic()
2619 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); in create_hp_mic()
2625 spec->hp_mic = 0; /* clear once */ in create_hp_mic()
2626 if (cfg->num_inputs >= AUTO_CFG_MAX_INS) in create_hp_mic()
2630 if (cfg->line_out_type == AUTO_PIN_HP_OUT && cfg->line_outs > 0) in create_hp_mic()
2631 nid = cfg->line_out_pins[0]; in create_hp_mic()
2632 else if (cfg->hp_outs > 0) in create_hp_mic()
2633 nid = cfg->hp_pins[0]; in create_hp_mic()
2640 cfg->inputs[cfg->num_inputs].pin = nid; in create_hp_mic()
2641 cfg->inputs[cfg->num_inputs].type = AUTO_PIN_MIC; in create_hp_mic()
2642 cfg->inputs[cfg->num_inputs].is_headphone_mic = 1; in create_hp_mic()
2643 cfg->num_inputs++; in create_hp_mic()
2644 spec->hp_mic = 1; in create_hp_mic()
2645 spec->hp_mic_pin = nid; in create_hp_mic()
2646 /* we can't handle auto-mic together with HP-mic */ in create_hp_mic()
2647 spec->suppress_auto_mic = 1; in create_hp_mic()
2672 hda_nid_t nid = kcontrol->private_value; in out_jack_mode_get()
2674 ucontrol->value.enumerated.item[0] = 1; in out_jack_mode_get()
2676 ucontrol->value.enumerated.item[0] = 0; in out_jack_mode_get()
2684 hda_nid_t nid = kcontrol->private_value; in out_jack_mode_put()
2687 val = ucontrol->value.enumerated.item[0] ? PIN_HP : PIN_OUT; in out_jack_mode_put()
2703 struct hda_gen_spec *spec = codec->spec; in find_kctl_name()
2707 snd_array_for_each(&spec->kctls, i, kctl) { in find_kctl_name()
2708 if (!strcmp(kctl->name, name) && kctl->index == idx) in find_kctl_name()
2717 struct hda_gen_spec *spec = codec->spec; in get_jack_mode_name()
2720 snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len, &idx); in get_jack_mode_name()
2729 struct hda_gen_spec *spec = codec->spec; in get_out_jack_num_items()
2730 if (spec->add_jack_modes) { in get_out_jack_num_items()
2741 struct hda_gen_spec *spec = codec->spec; in create_out_jack_modes()
2746 if (pin == spec->hp_mic_pin) in create_out_jack_modes()
2755 return -ENOMEM; in create_out_jack_modes()
2756 knew->private_value = pin; in create_out_jack_modes()
2771 "Line In", "Mic 50pc Bias", "Mic 0V Bias",
2772 "", "Mic 80pc Bias", "Mic 100pc Bias"
2819 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_info()
2825 strcpy(uinfo->value.enumerated.name, in in_jack_mode_info()
2826 vref_texts[get_vref_idx(vref_caps, uinfo->value.enumerated.item)]); in in_jack_mode_info()
2834 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_get()
2839 ucontrol->value.enumerated.item[0] = cvt_from_vref_idx(vref_caps, idx); in in_jack_mode_get()
2847 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_put()
2853 if (idx == ucontrol->value.enumerated.item[0]) in in_jack_mode_put()
2857 val |= get_vref_idx(vref_caps, ucontrol->value.enumerated.item[0]); in in_jack_mode_put()
2871 struct hda_gen_spec *spec = codec->spec; in get_in_jack_num_items()
2873 if (spec->add_jack_modes) in get_in_jack_num_items()
2880 struct hda_gen_spec *spec = codec->spec; in create_in_jack_mode()
2885 if (pin == spec->hp_mic_pin) in create_in_jack_mode()
2900 return -ENOMEM; in create_in_jack_mode()
2901 knew->private_value = pin; in create_in_jack_mode()
2906 * HP/mic shared jack mode
2912 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_info()
2918 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in hp_mic_jack_mode_info()
2919 uinfo->count = 1; in hp_mic_jack_mode_info()
2920 uinfo->value.enumerated.items = out_jacks + in_jacks; in hp_mic_jack_mode_info()
2921 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) in hp_mic_jack_mode_info()
2922 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; in hp_mic_jack_mode_info()
2923 idx = uinfo->value.enumerated.item; in hp_mic_jack_mode_info()
2930 idx -= out_jacks; in hp_mic_jack_mode_info()
2935 text = "Mic In"; in hp_mic_jack_mode_info()
2938 strcpy(uinfo->value.enumerated.name, text); in hp_mic_jack_mode_info()
2967 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_get()
2968 ucontrol->value.enumerated.item[0] = in hp_mic_jack_mode_get()
2977 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_put()
2983 idx = ucontrol->value.enumerated.item[0]; in hp_mic_jack_mode_put()
2993 idx -= out_jacks; in hp_mic_jack_mode_put()
3017 struct hda_gen_spec *spec = codec->spec; in create_hp_mic_jack_mode()
3020 knew = snd_hda_gen_add_kctl(spec, "Headphone Mic Jack Mode", in create_hp_mic_jack_mode()
3023 return -ENOMEM; in create_hp_mic_jack_mode()
3024 knew->private_value = pin; in create_hp_mic_jack_mode()
3025 spec->hp_mic_jack_modes = 1; in create_hp_mic_jack_mode()
3033 /* add the powersave loopback-list entry */
3038 list = snd_array_new(&spec->loopback_list); in add_loopback_list()
3040 return -ENOMEM; in add_loopback_list()
3041 list->nid = mix; in add_loopback_list()
3042 list->dir = HDA_INPUT; in add_loopback_list()
3043 list->idx = idx; in add_loopback_list()
3044 spec->loopback.amplist = spec->loopback_list.list; in add_loopback_list()
3091 struct hda_gen_spec *spec = codec->spec; in new_analog_input()
3101 return -EINVAL; in new_analog_input()
3103 spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path); in new_analog_input()
3105 idx = path->idx[path->depth - 1]; in new_analog_input()
3110 path->ctls[NID_PATH_VOL_CTL] = mix_val; in new_analog_input()
3117 path->ctls[NID_PATH_MUTE_CTL] = mute_val; in new_analog_input()
3120 path->active = true; in new_analog_input()
3121 path->stream_enabled = true; /* no DAC/ADC involved */ in new_analog_input()
3126 if (spec->mixer_nid != spec->mixer_merge_nid && in new_analog_input()
3127 !spec->loopback_merge_path) { in new_analog_input()
3128 path = snd_hda_add_new_path(codec, spec->mixer_nid, in new_analog_input()
3129 spec->mixer_merge_nid, 0); in new_analog_input()
3131 print_nid_path(codec, "loopback-merge", path); in new_analog_input()
3132 path->active = true; in new_analog_input()
3133 path->pin_fixed = true; /* static route */ in new_analog_input()
3134 path->stream_enabled = true; /* no DAC/ADC involved */ in new_analog_input()
3135 spec->loopback_merge_path = in new_analog_input()
3152 struct hda_gen_spec *spec = codec->spec; in fill_adc_nids()
3154 hda_nid_t *adc_nids = spec->adc_nids; in fill_adc_nids()
3155 int max_nums = ARRAY_SIZE(spec->adc_nids); in fill_adc_nids()
3168 spec->num_adc_nids = nums; in fill_adc_nids()
3171 spec->num_all_adcs = nums; in fill_adc_nids()
3172 memcpy(spec->all_adcs, spec->adc_nids, nums * sizeof(hda_nid_t)); in fill_adc_nids()
3178 * if needed, check whether dynamic ADC-switching is available
3182 struct hda_gen_spec *spec = codec->spec; in check_dyn_adc_switch()
3183 struct hda_input_mux *imux = &spec->input_mux; in check_dyn_adc_switch()
3189 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3190 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3191 if (!spec->input_paths[i][n]) in check_dyn_adc_switch()
3194 if (i >= imux->num_items) { in check_dyn_adc_switch()
3201 /* check whether ADC-switch is possible */ in check_dyn_adc_switch()
3202 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3203 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3204 if (spec->input_paths[i][n]) { in check_dyn_adc_switch()
3205 spec->dyn_adc_idx[i] = n; in check_dyn_adc_switch()
3212 spec->dyn_adc_switch = 1; in check_dyn_adc_switch()
3213 } else if (nums != spec->num_adc_nids) { in check_dyn_adc_switch()
3216 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3220 spec->adc_nids[nums] = spec->adc_nids[n]; in check_dyn_adc_switch()
3221 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3223 spec->input_paths[i][nums]); in check_dyn_adc_switch()
3224 spec->input_paths[i][nums] = in check_dyn_adc_switch()
3225 spec->input_paths[i][n]; in check_dyn_adc_switch()
3226 spec->input_paths[i][n] = 0; in check_dyn_adc_switch()
3231 spec->num_adc_nids = nums; in check_dyn_adc_switch()
3234 if (imux->num_items == 1 || in check_dyn_adc_switch()
3235 (imux->num_items == 2 && spec->hp_mic)) { in check_dyn_adc_switch()
3237 spec->num_adc_nids = 1; /* reduce to a single ADC */ in check_dyn_adc_switch()
3241 if (!spec->dyn_adc_switch && spec->multi_cap_vol) in check_dyn_adc_switch()
3242 spec->num_adc_nids = 1; in check_dyn_adc_switch()
3252 struct hda_gen_spec *spec = codec->spec; in parse_capture_source()
3253 struct hda_input_mux *imux = &spec->input_mux; in parse_capture_source()
3254 int imux_idx = imux->num_items; in parse_capture_source()
3260 hda_nid_t adc = spec->adc_nids[c]; in parse_capture_source()
3268 spec->input_paths[imux_idx][c] = in parse_capture_source()
3272 if (spec->hp_mic_pin == pin) in parse_capture_source()
3273 spec->hp_mic_mux_idx = imux->num_items; in parse_capture_source()
3274 spec->imux_pins[imux->num_items] = pin; in parse_capture_source()
3277 if (spec->dyn_adc_switch) in parse_capture_source()
3278 spec->dyn_adc_idx[imux_idx] = c; in parse_capture_source()
3292 struct hda_gen_spec *spec = codec->spec; in fill_input_pin_labels()
3293 const struct auto_pin_cfg *cfg = &spec->autocfg; in fill_input_pin_labels() local
3296 for (i = 0; i < cfg->num_inputs; i++) { in fill_input_pin_labels()
3297 hda_nid_t pin = cfg->inputs[i].pin; in fill_input_pin_labels()
3304 label = hda_get_autocfg_input_label(codec, cfg, i); in fill_input_pin_labels()
3306 for (j = i - 1; j >= 0; j--) { in fill_input_pin_labels()
3307 if (spec->input_labels[j] && in fill_input_pin_labels()
3308 !strcmp(spec->input_labels[j], label)) { in fill_input_pin_labels()
3309 idx = spec->input_label_idxs[j] + 1; in fill_input_pin_labels()
3314 spec->input_labels[i] = label; in fill_input_pin_labels()
3315 spec->input_label_idxs[i] = idx; in fill_input_pin_labels()
3321 #define CFG_IDX_MIX 99 /* a dummy cfg->input idx for stereo mix */
3325 struct hda_gen_spec *spec = codec->spec; in create_input_ctls()
3326 const struct auto_pin_cfg *cfg = &spec->autocfg; in create_input_ctls() local
3327 hda_nid_t mixer = spec->mixer_nid; in create_input_ctls()
3340 for (i = 0; i < cfg->num_inputs; i++) { in create_input_ctls()
3343 pin = cfg->inputs[i].pin; in create_input_ctls()
3348 if (cfg->inputs[i].type == AUTO_PIN_MIC) in create_input_ctls()
3350 if (pin != spec->hp_mic_pin && in create_input_ctls()
3357 spec->input_labels[i], in create_input_ctls()
3358 spec->input_label_idxs[i], in create_input_ctls()
3366 spec->input_labels[i], -mixer); in create_input_ctls()
3370 if (spec->add_jack_modes) { in create_input_ctls()
3378 if (mixer && spec->add_stereo_mix_input == HDA_HINT_STEREO_MIX_ENABLE) { in create_input_ctls()
3384 spec->suppress_auto_mic = 1; in create_input_ctls()
3398 struct hda_gen_spec *spec = codec->spec; in get_input_path()
3403 if (spec->dyn_adc_switch) in get_input_path()
3404 adc_idx = spec->dyn_adc_idx[imux_idx]; in get_input_path()
3409 return snd_hda_get_path_from_idx(codec, spec->input_paths[imux_idx][adc_idx]); in get_input_path()
3419 struct hda_gen_spec *spec = codec->spec; in mux_enum_info()
3420 return snd_hda_input_mux_info(&spec->input_mux, uinfo); in mux_enum_info()
3427 struct hda_gen_spec *spec = codec->spec; in mux_enum_get()
3429 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in mux_enum_get()
3431 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; in mux_enum_get()
3439 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in mux_enum_put()
3441 ucontrol->value.enumerated.item[0]); in mux_enum_put()
3465 struct hda_gen_spec *spec = codec->spec; in cap_put_caller()
3470 imux = &spec->input_mux; in cap_put_caller()
3471 adc_idx = kcontrol->id.index; in cap_put_caller()
3472 mutex_lock(&codec->control_mutex); in cap_put_caller()
3473 for (i = 0; i < imux->num_items; i++) { in cap_put_caller()
3475 if (!path || !path->ctls[type]) in cap_put_caller()
3477 kcontrol->private_value = path->ctls[type]; in cap_put_caller()
3486 mutex_unlock(&codec->control_mutex); in cap_put_caller()
3487 if (err >= 0 && spec->cap_sync_hook) in cap_put_caller()
3488 spec->cap_sync_hook(codec, kcontrol, ucontrol); in cap_put_caller()
3542 path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0; in parse_capvol_in_path()
3544 if (depth >= path->depth) in parse_capvol_in_path()
3545 return -EINVAL; in parse_capvol_in_path()
3546 i = path->depth - depth - 1; in parse_capvol_in_path()
3547 nid = path->path[i]; in parse_capvol_in_path()
3548 if (!path->ctls[NID_PATH_VOL_CTL]) { in parse_capvol_in_path()
3550 path->ctls[NID_PATH_VOL_CTL] = in parse_capvol_in_path()
3553 int idx = path->idx[i]; in parse_capvol_in_path()
3554 if (!depth && codec->single_adc_amp) in parse_capvol_in_path()
3556 path->ctls[NID_PATH_VOL_CTL] = in parse_capvol_in_path()
3560 if (!path->ctls[NID_PATH_MUTE_CTL]) { in parse_capvol_in_path()
3562 path->ctls[NID_PATH_MUTE_CTL] = in parse_capvol_in_path()
3565 int idx = path->idx[i]; in parse_capvol_in_path()
3566 if (!depth && codec->single_adc_amp) in parse_capvol_in_path()
3568 path->ctls[NID_PATH_MUTE_CTL] = in parse_capvol_in_path()
3578 struct hda_gen_spec *spec = codec->spec; in is_inv_dmic_pin()
3579 struct auto_pin_cfg *cfg = &spec->autocfg; in is_inv_dmic_pin() local
3583 if (!spec->inv_dmic_split) in is_inv_dmic_pin()
3585 for (i = 0; i < cfg->num_inputs; i++) { in is_inv_dmic_pin()
3586 if (cfg->inputs[i].pin != nid) in is_inv_dmic_pin()
3588 if (cfg->inputs[i].type != AUTO_PIN_MIC) in is_inv_dmic_pin()
3601 struct hda_gen_spec *spec = codec->spec; in cap_single_sw_put()
3608 if (spec->cap_sync_hook) in cap_single_sw_put()
3609 spec->cap_sync_hook(codec, kcontrol, ucontrol); in cap_single_sw_put()
3618 struct hda_gen_spec *spec = codec->spec; in add_single_cap_ctl()
3637 return -ENOMEM; in add_single_cap_ctl()
3639 knew->put = cap_single_sw_put; in add_single_cap_ctl()
3653 return -ENOMEM; in add_single_cap_ctl()
3655 knew->put = cap_single_sw_put; in add_single_cap_ctl()
3678 struct hda_gen_spec *spec = codec->spec; in create_bind_cap_vol_ctl()
3684 return -ENOMEM; in create_bind_cap_vol_ctl()
3685 knew->index = idx; in create_bind_cap_vol_ctl()
3686 knew->private_value = vol_ctl; in create_bind_cap_vol_ctl()
3687 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in create_bind_cap_vol_ctl()
3692 return -ENOMEM; in create_bind_cap_vol_ctl()
3693 knew->index = idx; in create_bind_cap_vol_ctl()
3694 knew->private_value = sw_ctl; in create_bind_cap_vol_ctl()
3695 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in create_bind_cap_vol_ctl()
3710 ctl = path->ctls[type]; in get_first_cap_ctl()
3713 for (i = 0; i < idx - 1; i++) { in get_first_cap_ctl()
3715 if (path && path->ctls[type] == ctl) in get_first_cap_ctl()
3724 struct hda_gen_spec *spec = codec->spec; in create_multi_cap_vol_ctl()
3725 struct hda_input_mux *imux = &spec->input_mux; in create_multi_cap_vol_ctl()
3728 for (i = 0; i < imux->num_items; i++) { in create_multi_cap_vol_ctl()
3732 idx = imux->items[i].index; in create_multi_cap_vol_ctl()
3733 if (idx >= spec->autocfg.num_inputs) in create_multi_cap_vol_ctl()
3735 inv_dmic = is_inv_dmic_pin(codec, spec->imux_pins[i]); in create_multi_cap_vol_ctl()
3739 spec->input_labels[idx], in create_multi_cap_vol_ctl()
3740 spec->input_label_idxs[idx], in create_multi_cap_vol_ctl()
3753 struct hda_gen_spec *spec = codec->spec; in create_capture_mixers()
3754 struct hda_input_mux *imux = &spec->input_mux; in create_capture_mixers()
3757 if (spec->dyn_adc_switch) in create_capture_mixers()
3760 nums = spec->num_adc_nids; in create_capture_mixers()
3762 if (!spec->auto_mic && imux->num_items > 1) { in create_capture_mixers()
3768 return -ENOMEM; in create_capture_mixers()
3769 knew->count = nums; in create_capture_mixers()
3774 bool multi_cap_vol = spec->multi_cap_vol; in create_capture_mixers()
3779 for (i = 0; i < imux->num_items; i++) { in create_capture_mixers()
3786 vol = path->ctls[NID_PATH_VOL_CTL]; in create_capture_mixers()
3787 else if (vol != path->ctls[NID_PATH_VOL_CTL]) { in create_capture_mixers()
3790 path->ctls[NID_PATH_VOL_CTL], HDA_INPUT)) in create_capture_mixers()
3794 sw = path->ctls[NID_PATH_MUTE_CTL]; in create_capture_mixers()
3795 else if (sw != path->ctls[NID_PATH_MUTE_CTL]) { in create_capture_mixers()
3798 path->ctls[NID_PATH_MUTE_CTL], HDA_INPUT)) in create_capture_mixers()
3801 if (is_inv_dmic_pin(codec, spec->imux_pins[i])) in create_capture_mixers()
3820 * add mic boosts if needed
3850 if (depth >= path->depth - 1) in look_for_boost_amp()
3852 nid = path->path[depth]; in look_for_boost_amp()
3857 path->idx[depth])) { in look_for_boost_amp()
3858 val = HDA_COMPOSE_AMP_VAL(nid, 3, path->idx[depth], in look_for_boost_amp()
3869 struct hda_gen_spec *spec = codec->spec; in parse_mic_boost()
3870 struct auto_pin_cfg *cfg = &spec->autocfg; in parse_mic_boost() local
3871 struct hda_input_mux *imux = &spec->input_mux; in parse_mic_boost()
3874 if (!spec->num_adc_nids) in parse_mic_boost()
3877 for (i = 0; i < imux->num_items; i++) { in parse_mic_boost()
3883 idx = imux->items[i].index; in parse_mic_boost()
3884 if (idx >= imux->num_items) in parse_mic_boost()
3887 /* check only line-in and mic pins */ in parse_mic_boost()
3888 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN) in parse_mic_boost()
3901 "%s Boost Volume", spec->input_labels[idx]); in parse_mic_boost()
3903 spec->input_label_idxs[idx], val)) in parse_mic_boost()
3904 return -ENOMEM; in parse_mic_boost()
3906 path->ctls[NID_PATH_BOOST_CTL] = val; in parse_mic_boost()
3921 struct hda_gen_spec *spec = codec->spec; in create_mute_led_cdev()
3926 cdev = devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); in create_mute_led_cdev()
3928 return -ENOMEM; in create_mute_led_cdev()
3930 cdev->name = micmute ? "hda::micmute" : "hda::mute"; in create_mute_led_cdev()
3931 cdev->max_brightness = 1; in create_mute_led_cdev()
3932 cdev->default_trigger = micmute ? "audio-micmute" : "audio-mute"; in create_mute_led_cdev()
3933 cdev->brightness_set_blocking = callback; in create_mute_led_cdev()
3934 cdev->brightness = ledtrig_audio_get(idx); in create_mute_led_cdev()
3935 cdev->flags = LED_CORE_SUSPENDRESUME; in create_mute_led_cdev()
3937 err = led_classdev_register(&codec->core.dev, cdev); in create_mute_led_cdev()
3940 spec->led_cdevs[idx] = cdev; in create_mute_led_cdev()
3950 * snd_dha_gen_add_mute_led_cdev - Create a LED classdev and enable as vmaster mute LED
3958 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_add_mute_led_cdev()
3969 if (spec->vmaster_mute.hook) in snd_hda_gen_add_mute_led_cdev()
3972 spec->vmaster_mute.hook = vmaster_update_mute_led; in snd_hda_gen_add_mute_led_cdev()
3973 spec->vmaster_mute_enum = 1; in snd_hda_gen_add_mute_led_cdev()
3979 * mic mute LED hook helpers
3990 struct hda_gen_spec *spec = codec->spec; in call_micmute_led_update()
3993 switch (spec->micmute_led.led_mode) { in call_micmute_led_update()
4001 val = !!spec->micmute_led.capture; in call_micmute_led_update()
4005 val = !spec->micmute_led.capture; in call_micmute_led_update()
4009 if (val == spec->micmute_led.led_value) in call_micmute_led_update()
4011 spec->micmute_led.led_value = val; in call_micmute_led_update()
4013 spec->micmute_led.led_value ? LED_ON : LED_OFF); in call_micmute_led_update()
4020 struct hda_gen_spec *spec = codec->spec; in update_micmute_led()
4023 if (spec->micmute_led.old_hook) in update_micmute_led()
4024 spec->micmute_led.old_hook(codec, kcontrol, ucontrol); in update_micmute_led()
4028 mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in update_micmute_led()
4029 if (!strcmp("Capture Switch", ucontrol->id.name)) { in update_micmute_led()
4031 if (ucontrol->value.integer.value[0] || in update_micmute_led()
4032 ucontrol->value.integer.value[1]) in update_micmute_led()
4033 spec->micmute_led.capture |= mask; in update_micmute_led()
4035 spec->micmute_led.capture &= ~mask; in update_micmute_led()
4054 struct hda_gen_spec *spec = codec->spec; in micmute_led_mode_get()
4056 ucontrol->value.enumerated.item[0] = spec->micmute_led.led_mode; in micmute_led_mode_get()
4064 struct hda_gen_spec *spec = codec->spec; in micmute_led_mode_put()
4067 mode = ucontrol->value.enumerated.item[0]; in micmute_led_mode_put()
4070 if (mode == spec->micmute_led.led_mode) in micmute_led_mode_put()
4072 spec->micmute_led.led_mode = mode; in micmute_led_mode_put()
4079 .name = "Mic Mute-LED Mode",
4085 /* Set up the capture sync hook for controlling the mic-mute LED */
4088 struct hda_gen_spec *spec = codec->spec; in add_micmute_led_hook()
4090 spec->micmute_led.led_mode = MICMUTE_LED_FOLLOW_MUTE; in add_micmute_led_hook()
4091 spec->micmute_led.capture = 0; in add_micmute_led_hook()
4092 spec->micmute_led.led_value = -1; in add_micmute_led_hook()
4093 spec->micmute_led.old_hook = spec->cap_sync_hook; in add_micmute_led_hook()
4094 spec->cap_sync_hook = update_micmute_led; in add_micmute_led_hook()
4096 return -ENOMEM; in add_micmute_led_hook()
4101 * snd_dha_gen_add_micmute_led_cdev - Create a LED classdev and enable as mic-mute LED
4105 * Called from the codec drivers for offering the mic mute LED controls.
4110 * LED-trigger is set up.
4123 codec_warn(codec, "failed to create a mic-mute LED cdev\n"); in snd_hda_gen_add_micmute_led_cdev()
4134 * parse digital I/Os and set up NIDs in BIOS auto-parse mode
4138 struct hda_gen_spec *spec = codec->spec; in parse_digital()
4145 for (i = 0; i < spec->autocfg.dig_outs; i++) { in parse_digital()
4146 pin = spec->autocfg.dig_out_pins[i]; in parse_digital()
4154 path->active = true; in parse_digital()
4155 path->pin_fixed = true; /* no jack detection */ in parse_digital()
4156 spec->digout_paths[i] = snd_hda_get_path_idx(codec, path); in parse_digital()
4159 spec->multiout.dig_out_nid = dig_nid; in parse_digital()
4160 spec->dig_out_type = spec->autocfg.dig_out_type[0]; in parse_digital()
4162 spec->multiout.follower_dig_outs = spec->follower_dig_outs; in parse_digital()
4163 if (nums >= ARRAY_SIZE(spec->follower_dig_outs) - 1) in parse_digital()
4165 spec->follower_dig_outs[nums - 1] = dig_nid; in parse_digital()
4170 if (spec->autocfg.dig_in_pin) { in parse_digital()
4171 pin = spec->autocfg.dig_in_pin; in parse_digital()
4181 path->active = true; in parse_digital()
4182 path->pin_fixed = true; /* no jack */ in parse_digital()
4183 spec->dig_in_nid = dig_nid; in parse_digital()
4184 spec->digin_path = snd_hda_get_path_idx(codec, path); in parse_digital()
4203 struct hda_gen_spec *spec = codec->spec; in mux_select()
4207 imux = &spec->input_mux; in mux_select()
4208 if (!imux->num_items) in mux_select()
4211 if (idx >= imux->num_items) in mux_select()
4212 idx = imux->num_items - 1; in mux_select()
4213 if (spec->cur_mux[adc_idx] == idx) in mux_select()
4216 old_path = get_input_path(codec, adc_idx, spec->cur_mux[adc_idx]); in mux_select()
4219 if (old_path->active) in mux_select()
4222 spec->cur_mux[adc_idx] = idx; in mux_select()
4224 if (spec->hp_mic) in mux_select()
4227 if (spec->dyn_adc_switch) in mux_select()
4233 if (path->active) in mux_select()
4236 if (spec->cap_sync_hook) in mux_select()
4237 spec->cap_sync_hook(codec, NULL, NULL); in mux_select()
4243 * as terminals (either start- or endpoint)
4250 struct hda_gen_spec *spec = codec->spec; in set_path_power()
4255 snd_array_for_each(&spec->paths, n, path) { in set_path_power()
4256 if (!path->depth) in set_path_power()
4258 if (path->path[0] == nid || in set_path_power()
4259 path->path[path->depth - 1] == nid) { in set_path_power()
4260 bool pin_old = path->pin_enabled; in set_path_power()
4261 bool stream_old = path->stream_enabled; in set_path_power()
4264 path->pin_enabled = pin_state; in set_path_power()
4266 path->stream_enabled = stream_state; in set_path_power()
4267 if ((!path->pin_fixed && path->pin_enabled != pin_old) in set_path_power()
4268 || path->stream_enabled != stream_old) { in set_path_power()
4297 if (!codec->power_save_node) in set_pin_power_jack()
4304 return set_path_power(codec, pin, on, -1); in set_pin_power_jack()
4311 if (jack && jack->nid) in pin_power_callback()
4313 set_pin_power_jack(codec, jack->nid, on)); in pin_power_callback()
4316 /* callback only doing power up -- called at first */
4323 /* callback only doing power down -- called at last */
4342 set_path_power(codec, pins[i], true, -1); in add_pin_power_ctls()
4351 struct hda_gen_spec *spec = codec->spec; in add_all_pin_power_ctls()
4352 struct auto_pin_cfg *cfg = &spec->autocfg; in add_all_pin_power_ctls() local
4355 if (!codec->power_save_node) in add_all_pin_power_ctls()
4357 add_pin_power_ctls(codec, cfg->line_outs, cfg->line_out_pins, on); in add_all_pin_power_ctls()
4358 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in add_all_pin_power_ctls()
4359 add_pin_power_ctls(codec, cfg->hp_outs, cfg->hp_pins, on); in add_all_pin_power_ctls()
4360 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in add_all_pin_power_ctls()
4361 add_pin_power_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, on); in add_all_pin_power_ctls()
4362 for (i = 0; i < cfg->num_inputs; i++) in add_all_pin_power_ctls()
4363 add_pin_power_ctls(codec, 1, &cfg->inputs[i].pin, on); in add_all_pin_power_ctls()
4374 set_pin_power_jack(codec, pins[i], -1); in sync_pin_power_ctls()
4380 struct hda_gen_spec *spec = codec->spec; in sync_all_pin_power_ctls()
4381 struct auto_pin_cfg *cfg = &spec->autocfg; in sync_all_pin_power_ctls() local
4384 if (!codec->power_save_node) in sync_all_pin_power_ctls()
4386 sync_pin_power_ctls(codec, cfg->line_outs, cfg->line_out_pins); in sync_all_pin_power_ctls()
4387 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in sync_all_pin_power_ctls()
4388 sync_pin_power_ctls(codec, cfg->hp_outs, cfg->hp_pins); in sync_all_pin_power_ctls()
4389 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in sync_all_pin_power_ctls()
4390 sync_pin_power_ctls(codec, cfg->speaker_outs, cfg->speaker_pins); in sync_all_pin_power_ctls()
4391 for (i = 0; i < cfg->num_inputs; i++) in sync_all_pin_power_ctls()
4392 sync_pin_power_ctls(codec, 1, &cfg->inputs[i].pin); in sync_all_pin_power_ctls()
4399 struct hda_gen_spec *spec = codec->spec; in add_fake_paths()
4408 path = snd_array_new(&spec->paths); in add_fake_paths()
4410 return -ENOMEM; in add_fake_paths()
4412 path->depth = 2; in add_fake_paths()
4413 path->path[0] = nid; in add_fake_paths()
4414 path->path[1] = pins[i]; in add_fake_paths()
4415 path->active = true; in add_fake_paths()
4423 struct hda_gen_spec *spec = codec->spec; in add_fake_beep_paths()
4424 struct auto_pin_cfg *cfg = &spec->autocfg; in add_fake_beep_paths() local
4425 hda_nid_t nid = spec->beep_nid; in add_fake_beep_paths()
4428 if (!codec->power_save_node || !nid) in add_fake_beep_paths()
4430 err = add_fake_paths(codec, nid, cfg->line_outs, cfg->line_out_pins); in add_fake_beep_paths()
4433 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in add_fake_beep_paths()
4434 err = add_fake_paths(codec, nid, cfg->hp_outs, cfg->hp_pins); in add_fake_beep_paths()
4438 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in add_fake_beep_paths()
4439 err = add_fake_paths(codec, nid, cfg->speaker_outs, in add_fake_beep_paths()
4440 cfg->speaker_pins); in add_fake_beep_paths()
4450 set_path_power(beep->codec, beep->nid, -1, on); in beep_power_hook()
4454 * snd_hda_gen_fix_pin_power - Fix the power of the given pin widget to D0
4460 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_fix_pin_power()
4463 path = snd_array_new(&spec->paths); in snd_hda_gen_fix_pin_power()
4465 return -ENOMEM; in snd_hda_gen_fix_pin_power()
4467 path->depth = 1; in snd_hda_gen_fix_pin_power()
4468 path->path[0] = pin; in snd_hda_gen_fix_pin_power()
4469 path->active = true; in snd_hda_gen_fix_pin_power()
4470 path->pin_fixed = true; in snd_hda_gen_fix_pin_power()
4471 path->stream_enabled = true; in snd_hda_gen_fix_pin_power()
4477 * Jack detections for HP auto-mute and mic-switch
4499 /* standard HP/line-out auto-mute helper */
4503 struct hda_gen_spec *spec = codec->spec; in do_automute()
4516 if (spec->auto_mute_via_amp) { in do_automute()
4523 mute_nid = get_amp_nid_(path->ctls[NID_PATH_MUTE_CTL]); in do_automute()
4527 spec->mute_bits |= (1ULL << mute_nid); in do_automute()
4529 spec->mute_bits &= ~(1ULL << mute_nid); in do_automute()
4535 if (spec->keep_vref_in_automute) in do_automute()
4550 if (codec->power_save_node) { in do_automute()
4554 set_path_power(codec, nid, on, -1); in do_automute()
4560 * snd_hda_gen_update_outputs - Toggle outputs muting
4567 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_update_outputs()
4575 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in snd_hda_gen_update_outputs()
4576 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4578 paths = spec->hp_paths; in snd_hda_gen_update_outputs()
4579 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), in snd_hda_gen_update_outputs()
4580 spec->autocfg.hp_pins, paths, spec->master_mute); in snd_hda_gen_update_outputs()
4582 if (!spec->automute_speaker) in snd_hda_gen_update_outputs()
4585 on = spec->hp_jack_present | spec->line_jack_present; in snd_hda_gen_update_outputs()
4586 on |= spec->master_mute; in snd_hda_gen_update_outputs()
4587 spec->speaker_muted = on; in snd_hda_gen_update_outputs()
4588 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_update_outputs()
4589 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4591 paths = spec->speaker_paths; in snd_hda_gen_update_outputs()
4592 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), in snd_hda_gen_update_outputs()
4593 spec->autocfg.speaker_pins, paths, on); in snd_hda_gen_update_outputs()
4595 /* toggle line-out mutes if needed, too */ in snd_hda_gen_update_outputs()
4597 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || in snd_hda_gen_update_outputs()
4598 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) in snd_hda_gen_update_outputs()
4600 if (!spec->automute_lo) in snd_hda_gen_update_outputs()
4603 on = spec->hp_jack_present; in snd_hda_gen_update_outputs()
4604 on |= spec->master_mute; in snd_hda_gen_update_outputs()
4605 spec->line_out_muted = on; in snd_hda_gen_update_outputs()
4606 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4607 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), in snd_hda_gen_update_outputs()
4608 spec->autocfg.line_out_pins, paths, on); in snd_hda_gen_update_outputs()
4614 struct hda_gen_spec *spec = codec->spec; in call_update_outputs()
4615 if (spec->automute_hook) in call_update_outputs()
4616 spec->automute_hook(codec); in call_update_outputs()
4620 /* sync the whole vmaster followers to reflect the new auto-mute status */ in call_update_outputs()
4621 if (spec->auto_mute_via_amp && !codec->bus->shutdown) in call_update_outputs()
4622 snd_ctl_sync_vmaster(spec->vmaster_mute.sw_kctl, false); in call_update_outputs()
4626 * snd_hda_gen_hp_automute - standard HP-automute helper
4633 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_hp_automute()
4634 hda_nid_t *pins = spec->autocfg.hp_pins; in snd_hda_gen_hp_automute()
4635 int num_pins = ARRAY_SIZE(spec->autocfg.hp_pins); in snd_hda_gen_hp_automute()
4637 /* No detection for the first HP jack during indep-HP mode */ in snd_hda_gen_hp_automute()
4638 if (spec->indep_hp_enabled) { in snd_hda_gen_hp_automute()
4640 num_pins--; in snd_hda_gen_hp_automute()
4643 spec->hp_jack_present = detect_jacks(codec, num_pins, pins); in snd_hda_gen_hp_automute()
4644 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) in snd_hda_gen_hp_automute()
4651 * snd_hda_gen_line_automute - standard line-out-automute helper
4658 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_line_automute()
4660 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_line_automute()
4663 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) in snd_hda_gen_line_automute()
4666 spec->line_jack_present = in snd_hda_gen_line_automute()
4667 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), in snd_hda_gen_line_automute()
4668 spec->autocfg.line_out_pins); in snd_hda_gen_line_automute()
4669 if (!spec->automute_speaker || !spec->detect_lo) in snd_hda_gen_line_automute()
4676 * snd_hda_gen_mic_autoswitch - standard mic auto-switch helper
4683 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_mic_autoswitch()
4686 if (!spec->auto_mic) in snd_hda_gen_mic_autoswitch()
4689 for (i = spec->am_num_entries - 1; i > 0; i--) { in snd_hda_gen_mic_autoswitch()
4690 hda_nid_t pin = spec->am_entry[i].pin; in snd_hda_gen_mic_autoswitch()
4695 mux_select(codec, 0, spec->am_entry[i].idx); in snd_hda_gen_mic_autoswitch()
4699 mux_select(codec, 0, spec->am_entry[0].idx); in snd_hda_gen_mic_autoswitch()
4707 struct hda_gen_spec *spec = codec->spec; in call_hp_automute()
4708 if (spec->hp_automute_hook) in call_hp_automute()
4709 spec->hp_automute_hook(codec, jack); in call_hp_automute()
4717 struct hda_gen_spec *spec = codec->spec; in call_line_automute()
4718 if (spec->line_automute_hook) in call_line_automute()
4719 spec->line_automute_hook(codec, jack); in call_line_automute()
4727 struct hda_gen_spec *spec = codec->spec; in call_mic_autoswitch()
4728 if (spec->mic_autoswitch_hook) in call_mic_autoswitch()
4729 spec->mic_autoswitch_hook(codec, jack); in call_mic_autoswitch()
4743 * Auto-Mute mode mixer enum support
4749 struct hda_gen_spec *spec = codec->spec; in automute_mode_info()
4754 if (spec->automute_speaker_possible && spec->automute_lo_possible) in automute_mode_info()
4763 struct hda_gen_spec *spec = codec->spec; in automute_mode_get()
4765 if (spec->automute_speaker) in automute_mode_get()
4767 if (spec->automute_lo) in automute_mode_get()
4770 ucontrol->value.enumerated.item[0] = val; in automute_mode_get()
4778 struct hda_gen_spec *spec = codec->spec; in automute_mode_put()
4780 switch (ucontrol->value.enumerated.item[0]) { in automute_mode_put()
4782 if (!spec->automute_speaker && !spec->automute_lo) in automute_mode_put()
4784 spec->automute_speaker = 0; in automute_mode_put()
4785 spec->automute_lo = 0; in automute_mode_put()
4788 if (spec->automute_speaker_possible) { in automute_mode_put()
4789 if (!spec->automute_lo && spec->automute_speaker) in automute_mode_put()
4791 spec->automute_speaker = 1; in automute_mode_put()
4792 spec->automute_lo = 0; in automute_mode_put()
4793 } else if (spec->automute_lo_possible) { in automute_mode_put()
4794 if (spec->automute_lo) in automute_mode_put()
4796 spec->automute_lo = 1; in automute_mode_put()
4798 return -EINVAL; in automute_mode_put()
4801 if (!spec->automute_lo_possible || !spec->automute_speaker_possible) in automute_mode_put()
4802 return -EINVAL; in automute_mode_put()
4803 if (spec->automute_speaker && spec->automute_lo) in automute_mode_put()
4805 spec->automute_speaker = 1; in automute_mode_put()
4806 spec->automute_lo = 1; in automute_mode_put()
4809 return -EINVAL; in automute_mode_put()
4817 .name = "Auto-Mute Mode",
4825 struct hda_gen_spec *spec = codec->spec; in add_automute_mode_enum()
4828 return -ENOMEM; in add_automute_mode_enum()
4833 * Check the availability of HP/line-out auto-mute;
4838 struct hda_gen_spec *spec = codec->spec; in check_auto_mute_availability()
4839 struct auto_pin_cfg *cfg = &spec->autocfg; in check_auto_mute_availability() local
4843 if (spec->suppress_auto_mute) in check_auto_mute_availability()
4846 if (cfg->hp_pins[0]) in check_auto_mute_availability()
4848 if (cfg->line_out_pins[0]) in check_auto_mute_availability()
4850 if (cfg->speaker_pins[0]) in check_auto_mute_availability()
4855 if (!cfg->speaker_pins[0] && in check_auto_mute_availability()
4856 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { in check_auto_mute_availability()
4857 memcpy(cfg->speaker_pins, cfg->line_out_pins, in check_auto_mute_availability()
4858 sizeof(cfg->speaker_pins)); in check_auto_mute_availability()
4859 cfg->speaker_outs = cfg->line_outs; in check_auto_mute_availability()
4862 if (!cfg->hp_pins[0] && in check_auto_mute_availability()
4863 cfg->line_out_type == AUTO_PIN_HP_OUT) { in check_auto_mute_availability()
4864 memcpy(cfg->hp_pins, cfg->line_out_pins, in check_auto_mute_availability()
4865 sizeof(cfg->hp_pins)); in check_auto_mute_availability()
4866 cfg->hp_outs = cfg->line_outs; in check_auto_mute_availability()
4869 for (i = 0; i < cfg->hp_outs; i++) { in check_auto_mute_availability()
4870 hda_nid_t nid = cfg->hp_pins[i]; in check_auto_mute_availability()
4873 codec_dbg(codec, "Enable HP auto-muting on NID 0x%x\n", nid); in check_auto_mute_availability()
4876 spec->detect_hp = 1; in check_auto_mute_availability()
4879 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { in check_auto_mute_availability()
4880 if (cfg->speaker_outs) in check_auto_mute_availability()
4881 for (i = 0; i < cfg->line_outs; i++) { in check_auto_mute_availability()
4882 hda_nid_t nid = cfg->line_out_pins[i]; in check_auto_mute_availability()
4885 codec_dbg(codec, "Enable Line-Out auto-muting on NID 0x%x\n", nid); in check_auto_mute_availability()
4888 spec->detect_lo = 1; in check_auto_mute_availability()
4890 spec->automute_lo_possible = spec->detect_hp; in check_auto_mute_availability()
4893 spec->automute_speaker_possible = cfg->speaker_outs && in check_auto_mute_availability()
4894 (spec->detect_hp || spec->detect_lo); in check_auto_mute_availability()
4896 spec->automute_lo = spec->automute_lo_possible; in check_auto_mute_availability()
4897 spec->automute_speaker = spec->automute_speaker_possible; in check_auto_mute_availability()
4899 if (spec->automute_speaker_possible || spec->automute_lo_possible) { in check_auto_mute_availability()
4908 /* check whether all auto-mic pins are valid; setup indices if OK */
4911 struct hda_gen_spec *spec = codec->spec; in auto_mic_check_imux()
4915 imux = &spec->input_mux; in auto_mic_check_imux()
4916 for (i = 0; i < spec->am_num_entries; i++) { in auto_mic_check_imux()
4917 spec->am_entry[i].idx = in auto_mic_check_imux()
4918 find_idx_in_nid_list(spec->am_entry[i].pin, in auto_mic_check_imux()
4919 spec->imux_pins, imux->num_items); in auto_mic_check_imux()
4920 if (spec->am_entry[i].idx < 0) in auto_mic_check_imux()
4925 for (i = 1; i < spec->am_num_entries; i++) in auto_mic_check_imux()
4927 spec->am_entry[i].pin, in auto_mic_check_imux()
4936 return (int)(a->attr - b->attr); in compare_attr()
4940 * Check the availability of auto-mic switch;
4945 struct hda_gen_spec *spec = codec->spec; in check_auto_mic_availability()
4946 struct auto_pin_cfg *cfg = &spec->autocfg; in check_auto_mic_availability() local
4950 if (spec->suppress_auto_mic) in check_auto_mic_availability()
4955 for (i = 0; i < cfg->num_inputs; i++) { in check_auto_mic_availability()
4956 hda_nid_t nid = cfg->inputs[i].pin; in check_auto_mic_availability()
4964 if (cfg->inputs[i].type != AUTO_PIN_MIC) in check_auto_mic_availability()
4970 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) in check_auto_mic_availability()
4972 if (!spec->line_in_auto_switch && in check_auto_mic_availability()
4973 cfg->inputs[i].type != AUTO_PIN_MIC) in check_auto_mic_availability()
4974 return 0; /* only mic is allowed */ in check_auto_mic_availability()
4982 spec->am_entry[num_pins].pin = nid; in check_auto_mic_availability()
4983 spec->am_entry[num_pins].attr = attr; in check_auto_mic_availability()
4990 spec->am_num_entries = num_pins; in check_auto_mic_availability()
4994 sort(spec->am_entry, num_pins, sizeof(spec->am_entry[0]), in check_auto_mic_availability()
5000 spec->auto_mic = 1; in check_auto_mic_availability()
5001 spec->num_adc_nids = 1; in check_auto_mic_availability()
5002 spec->cur_mux[0] = spec->am_entry[0].idx; in check_auto_mic_availability()
5003 codec_dbg(codec, "Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", in check_auto_mic_availability()
5004 spec->am_entry[0].pin, in check_auto_mic_availability()
5005 spec->am_entry[1].pin, in check_auto_mic_availability()
5006 spec->am_entry[2].pin); in check_auto_mic_availability()
5012 * snd_hda_gen_path_power_filter - power_filter hook to make inactive widgets
5022 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_path_power_filter()
5024 if (!spec->power_down_unused && !codec->power_save_node) in snd_hda_gen_path_power_filter()
5026 if (power_state != AC_PWRST_D0 || nid == codec->core.afg) in snd_hda_gen_path_power_filter()
5056 * snd_hda_gen_stream_pm - Stream power management callback
5065 if (codec->power_save_node) in snd_hda_gen_stream_pm()
5066 set_path_power(codec, nid, -1, on); in snd_hda_gen_stream_pm()
5071 * snd_hda_gen_parse_auto_config - Parse the given BIOS configuration and
5074 * @cfg: Parsed pin configuration
5080 struct auto_pin_cfg *cfg) in snd_hda_gen_parse_auto_config() argument
5082 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_parse_auto_config()
5087 if (spec->mixer_nid && !spec->mixer_merge_nid) in snd_hda_gen_parse_auto_config()
5088 spec->mixer_merge_nid = spec->mixer_nid; in snd_hda_gen_parse_auto_config()
5090 if (cfg != &spec->autocfg) { in snd_hda_gen_parse_auto_config()
5091 spec->autocfg = *cfg; in snd_hda_gen_parse_auto_config()
5092 cfg = &spec->autocfg; in snd_hda_gen_parse_auto_config()
5095 if (!spec->main_out_badness) in snd_hda_gen_parse_auto_config()
5096 spec->main_out_badness = &hda_main_out_badness; in snd_hda_gen_parse_auto_config()
5097 if (!spec->extra_out_badness) in snd_hda_gen_parse_auto_config()
5098 spec->extra_out_badness = &hda_extra_out_badness; in snd_hda_gen_parse_auto_config()
5102 if (!cfg->line_outs) { in snd_hda_gen_parse_auto_config()
5103 if (cfg->dig_outs || cfg->dig_in_pin) { in snd_hda_gen_parse_auto_config()
5104 spec->multiout.max_channels = 2; in snd_hda_gen_parse_auto_config()
5105 spec->no_analog = 1; in snd_hda_gen_parse_auto_config()
5108 if (!cfg->num_inputs && !cfg->dig_in_pin) in snd_hda_gen_parse_auto_config()
5112 if (!spec->no_primary_hp && in snd_hda_gen_parse_auto_config()
5113 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && in snd_hda_gen_parse_auto_config()
5114 cfg->line_outs <= cfg->hp_outs) { in snd_hda_gen_parse_auto_config()
5116 cfg->speaker_outs = cfg->line_outs; in snd_hda_gen_parse_auto_config()
5117 memcpy(cfg->speaker_pins, cfg->line_out_pins, in snd_hda_gen_parse_auto_config()
5118 sizeof(cfg->speaker_pins)); in snd_hda_gen_parse_auto_config()
5119 cfg->line_outs = cfg->hp_outs; in snd_hda_gen_parse_auto_config()
5120 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); in snd_hda_gen_parse_auto_config()
5121 cfg->hp_outs = 0; in snd_hda_gen_parse_auto_config()
5122 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); in snd_hda_gen_parse_auto_config()
5123 cfg->line_out_type = AUTO_PIN_HP_OUT; in snd_hda_gen_parse_auto_config()
5132 err = create_multi_out_ctls(codec, cfg); in snd_hda_gen_parse_auto_config()
5154 /* add power-down pin callbacks at first */ in snd_hda_gen_parse_auto_config()
5157 spec->const_channel_count = spec->ext_channel_count; in snd_hda_gen_parse_auto_config()
5159 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_parse_auto_config()
5160 spec->const_channel_count = max(spec->const_channel_count, in snd_hda_gen_parse_auto_config()
5161 cfg->speaker_outs * 2); in snd_hda_gen_parse_auto_config()
5162 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in snd_hda_gen_parse_auto_config()
5163 spec->const_channel_count = max(spec->const_channel_count, in snd_hda_gen_parse_auto_config()
5164 cfg->hp_outs * 2); in snd_hda_gen_parse_auto_config()
5165 spec->multiout.max_channels = max(spec->ext_channel_count, in snd_hda_gen_parse_auto_config()
5166 spec->const_channel_count); in snd_hda_gen_parse_auto_config()
5181 if (!spec->auto_mic && spec->mixer_nid && in snd_hda_gen_parse_auto_config()
5182 spec->add_stereo_mix_input == HDA_HINT_STEREO_MIX_AUTO && in snd_hda_gen_parse_auto_config()
5183 spec->input_mux.num_items > 1) { in snd_hda_gen_parse_auto_config()
5184 err = parse_capture_source(codec, spec->mixer_nid, in snd_hda_gen_parse_auto_config()
5185 CFG_IDX_MIX, spec->num_all_adcs, in snd_hda_gen_parse_auto_config()
5200 /* create "Headphone Mic Jack Mode" if no input selection is in snd_hda_gen_parse_auto_config()
5203 if (spec->hp_mic_pin && in snd_hda_gen_parse_auto_config()
5204 (spec->auto_mic || spec->input_mux.num_items == 1 || in snd_hda_gen_parse_auto_config()
5205 spec->add_jack_modes)) { in snd_hda_gen_parse_auto_config()
5206 err = create_hp_mic_jack_mode(codec, spec->hp_mic_pin); in snd_hda_gen_parse_auto_config()
5211 if (spec->add_jack_modes) { in snd_hda_gen_parse_auto_config()
5212 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in snd_hda_gen_parse_auto_config()
5213 err = create_out_jack_modes(codec, cfg->line_outs, in snd_hda_gen_parse_auto_config()
5214 cfg->line_out_pins); in snd_hda_gen_parse_auto_config()
5218 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in snd_hda_gen_parse_auto_config()
5219 err = create_out_jack_modes(codec, cfg->hp_outs, in snd_hda_gen_parse_auto_config()
5220 cfg->hp_pins); in snd_hda_gen_parse_auto_config()
5226 /* add power-up pin callbacks at last */ in snd_hda_gen_parse_auto_config()
5230 if (spec->mixer_nid) in snd_hda_gen_parse_auto_config()
5231 mute_all_mixer_nid(codec, spec->mixer_nid); in snd_hda_gen_parse_auto_config()
5236 if (spec->power_down_unused || codec->power_save_node) { in snd_hda_gen_parse_auto_config()
5237 if (!codec->power_filter) in snd_hda_gen_parse_auto_config()
5238 codec->power_filter = snd_hda_gen_path_power_filter; in snd_hda_gen_parse_auto_config()
5239 if (!codec->patch_ops.stream_pm) in snd_hda_gen_parse_auto_config()
5240 codec->patch_ops.stream_pm = snd_hda_gen_stream_pm; in snd_hda_gen_parse_auto_config()
5243 if (!spec->no_analog && spec->beep_nid) { in snd_hda_gen_parse_auto_config()
5244 err = snd_hda_attach_beep_device(codec, spec->beep_nid); in snd_hda_gen_parse_auto_config()
5247 if (codec->beep && codec->power_save_node) { in snd_hda_gen_parse_auto_config()
5251 codec->beep->power_hook = beep_power_hook; in snd_hda_gen_parse_auto_config()
5276 * snd_hda_gen_build_controls - Build controls from the parsed results
5283 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_build_controls()
5286 if (spec->kctls.used) { in snd_hda_gen_build_controls()
5287 err = snd_hda_add_new_ctls(codec, spec->kctls.list); in snd_hda_gen_build_controls()
5292 if (spec->multiout.dig_out_nid) { in snd_hda_gen_build_controls()
5294 spec->multiout.dig_out_nid, in snd_hda_gen_build_controls()
5295 spec->multiout.dig_out_nid, in snd_hda_gen_build_controls()
5296 spec->pcm_rec[1]->pcm_type); in snd_hda_gen_build_controls()
5299 if (!spec->no_analog) { in snd_hda_gen_build_controls()
5301 &spec->multiout); in snd_hda_gen_build_controls()
5304 spec->multiout.share_spdif = 1; in snd_hda_gen_build_controls()
5307 if (spec->dig_in_nid) { in snd_hda_gen_build_controls()
5308 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); in snd_hda_gen_build_controls()
5314 if (!spec->no_analog && !spec->suppress_vmaster && in snd_hda_gen_build_controls()
5317 spec->vmaster_tlv, follower_pfxs, in snd_hda_gen_build_controls()
5322 if (!spec->no_analog && !spec->suppress_vmaster && in snd_hda_gen_build_controls()
5327 true, &spec->vmaster_mute.sw_kctl); in snd_hda_gen_build_controls()
5330 if (spec->vmaster_mute.hook) { in snd_hda_gen_build_controls()
5331 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, in snd_hda_gen_build_controls()
5332 spec->vmaster_mute_enum); in snd_hda_gen_build_controls()
5333 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); in snd_hda_gen_build_controls()
5339 err = snd_hda_jack_add_kctls(codec, &spec->autocfg); in snd_hda_gen_build_controls()
5357 struct hda_gen_spec *spec = codec->spec; in call_pcm_playback_hook()
5358 if (spec->pcm_playback_hook) in call_pcm_playback_hook()
5359 spec->pcm_playback_hook(hinfo, codec, substream, action); in call_pcm_playback_hook()
5367 struct hda_gen_spec *spec = codec->spec; in call_pcm_capture_hook()
5368 if (spec->pcm_capture_hook) in call_pcm_capture_hook()
5369 spec->pcm_capture_hook(hinfo, codec, substream, action); in call_pcm_capture_hook()
5379 struct hda_gen_spec *spec = codec->spec; in playback_pcm_open()
5382 mutex_lock(&spec->pcm_mutex); in playback_pcm_open()
5384 &spec->multiout, substream, in playback_pcm_open()
5387 spec->active_streams |= 1 << STREAM_MULTI_OUT; in playback_pcm_open()
5391 mutex_unlock(&spec->pcm_mutex); in playback_pcm_open()
5401 struct hda_gen_spec *spec = codec->spec; in playback_pcm_prepare()
5404 err = snd_hda_multi_out_analog_prepare(codec, &spec->multiout, in playback_pcm_prepare()
5416 struct hda_gen_spec *spec = codec->spec; in playback_pcm_cleanup()
5419 err = snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); in playback_pcm_cleanup()
5430 struct hda_gen_spec *spec = codec->spec; in playback_pcm_close()
5431 mutex_lock(&spec->pcm_mutex); in playback_pcm_close()
5432 spec->active_streams &= ~(1 << STREAM_MULTI_OUT); in playback_pcm_close()
5435 mutex_unlock(&spec->pcm_mutex); in playback_pcm_close()
5453 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in capture_pcm_prepare()
5463 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in capture_pcm_cleanup()
5481 struct hda_gen_spec *spec = codec->spec; in alt_playback_pcm_open()
5484 mutex_lock(&spec->pcm_mutex); in alt_playback_pcm_open()
5485 if (spec->indep_hp && !spec->indep_hp_enabled) in alt_playback_pcm_open()
5486 err = -EBUSY; in alt_playback_pcm_open()
5488 spec->active_streams |= 1 << STREAM_INDEP_HP; in alt_playback_pcm_open()
5491 mutex_unlock(&spec->pcm_mutex); in alt_playback_pcm_open()
5499 struct hda_gen_spec *spec = codec->spec; in alt_playback_pcm_close()
5500 mutex_lock(&spec->pcm_mutex); in alt_playback_pcm_close()
5501 spec->active_streams &= ~(1 << STREAM_INDEP_HP); in alt_playback_pcm_close()
5504 mutex_unlock(&spec->pcm_mutex); in alt_playback_pcm_close()
5514 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in alt_playback_pcm_prepare()
5524 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in alt_playback_pcm_cleanup()
5537 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_open()
5538 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in dig_playback_pcm_open()
5547 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_prepare()
5548 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in dig_playback_pcm_prepare()
5556 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_cleanup()
5557 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); in dig_playback_pcm_cleanup()
5564 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_close()
5565 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in dig_playback_pcm_close()
5580 struct hda_gen_spec *spec = codec->spec; in alt_capture_pcm_prepare()
5582 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], in alt_capture_pcm_prepare()
5593 struct hda_gen_spec *spec = codec->spec; in alt_capture_pcm_cleanup()
5596 spec->adc_nids[substream->number + 1]); in alt_capture_pcm_cleanup()
5688 struct hda_gen_spec *spec = codec->spec; in dyn_adc_pcm_resetup()
5689 hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; in dyn_adc_pcm_resetup()
5691 if (spec->cur_adc && spec->cur_adc != new_adc) { in dyn_adc_pcm_resetup()
5693 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); in dyn_adc_pcm_resetup()
5694 spec->cur_adc = new_adc; in dyn_adc_pcm_resetup()
5696 spec->cur_adc_stream_tag, 0, in dyn_adc_pcm_resetup()
5697 spec->cur_adc_format); in dyn_adc_pcm_resetup()
5703 /* analog capture with dynamic dual-adc changes */
5710 struct hda_gen_spec *spec = codec->spec; in dyn_adc_capture_pcm_prepare()
5711 spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]]; in dyn_adc_capture_pcm_prepare()
5712 spec->cur_adc_stream_tag = stream_tag; in dyn_adc_capture_pcm_prepare()
5713 spec->cur_adc_format = format; in dyn_adc_capture_pcm_prepare()
5714 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); in dyn_adc_capture_pcm_prepare()
5723 struct hda_gen_spec *spec = codec->spec; in dyn_adc_capture_pcm_cleanup()
5724 snd_hda_codec_cleanup_stream(codec, spec->cur_adc); in dyn_adc_capture_pcm_cleanup()
5725 spec->cur_adc = 0; in dyn_adc_capture_pcm_cleanup()
5750 /* drop non-alnum chars after a space */ in fill_pcm_stream_name()
5760 /* copy PCM stream info from @default_str, and override non-NULL entries
5770 str->nid = nid; in setup_pcm_stream()
5772 if (spec_str->substreams) in setup_pcm_stream()
5773 str->substreams = spec_str->substreams; in setup_pcm_stream()
5774 if (spec_str->channels_min) in setup_pcm_stream()
5775 str->channels_min = spec_str->channels_min; in setup_pcm_stream()
5776 if (spec_str->channels_max) in setup_pcm_stream()
5777 str->channels_max = spec_str->channels_max; in setup_pcm_stream()
5778 if (spec_str->rates) in setup_pcm_stream()
5779 str->rates = spec_str->rates; in setup_pcm_stream()
5780 if (spec_str->formats) in setup_pcm_stream()
5781 str->formats = spec_str->formats; in setup_pcm_stream()
5782 if (spec_str->maxbps) in setup_pcm_stream()
5783 str->maxbps = spec_str->maxbps; in setup_pcm_stream()
5788 * snd_hda_gen_build_pcms - build PCM streams based on the parsed results
5795 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_build_pcms()
5799 if (spec->no_analog) in snd_hda_gen_build_pcms()
5802 fill_pcm_stream_name(spec->stream_name_analog, in snd_hda_gen_build_pcms()
5803 sizeof(spec->stream_name_analog), in snd_hda_gen_build_pcms()
5804 " Analog", codec->core.chip_name); in snd_hda_gen_build_pcms()
5805 info = snd_hda_codec_pcm_new(codec, "%s", spec->stream_name_analog); in snd_hda_gen_build_pcms()
5807 return -ENOMEM; in snd_hda_gen_build_pcms()
5808 spec->pcm_rec[0] = info; in snd_hda_gen_build_pcms()
5810 if (spec->multiout.num_dacs > 0) { in snd_hda_gen_build_pcms()
5811 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5813 spec->stream_analog_playback, in snd_hda_gen_build_pcms()
5814 spec->multiout.dac_nids[0]); in snd_hda_gen_build_pcms()
5815 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = in snd_hda_gen_build_pcms()
5816 spec->multiout.max_channels; in snd_hda_gen_build_pcms()
5817 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && in snd_hda_gen_build_pcms()
5818 spec->autocfg.line_outs == 2) in snd_hda_gen_build_pcms()
5819 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = in snd_hda_gen_build_pcms()
5822 if (spec->num_adc_nids) { in snd_hda_gen_build_pcms()
5823 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5824 (spec->dyn_adc_switch ? in snd_hda_gen_build_pcms()
5826 spec->stream_analog_capture, in snd_hda_gen_build_pcms()
5827 spec->adc_nids[0]); in snd_hda_gen_build_pcms()
5832 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { in snd_hda_gen_build_pcms()
5833 fill_pcm_stream_name(spec->stream_name_digital, in snd_hda_gen_build_pcms()
5834 sizeof(spec->stream_name_digital), in snd_hda_gen_build_pcms()
5835 " Digital", codec->core.chip_name); in snd_hda_gen_build_pcms()
5837 spec->stream_name_digital); in snd_hda_gen_build_pcms()
5839 return -ENOMEM; in snd_hda_gen_build_pcms()
5840 codec->follower_dig_outs = spec->multiout.follower_dig_outs; in snd_hda_gen_build_pcms()
5841 spec->pcm_rec[1] = info; in snd_hda_gen_build_pcms()
5842 if (spec->dig_out_type) in snd_hda_gen_build_pcms()
5843 info->pcm_type = spec->dig_out_type; in snd_hda_gen_build_pcms()
5845 info->pcm_type = HDA_PCM_TYPE_SPDIF; in snd_hda_gen_build_pcms()
5846 if (spec->multiout.dig_out_nid) in snd_hda_gen_build_pcms()
5847 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5849 spec->stream_digital_playback, in snd_hda_gen_build_pcms()
5850 spec->multiout.dig_out_nid); in snd_hda_gen_build_pcms()
5851 if (spec->dig_in_nid) in snd_hda_gen_build_pcms()
5852 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5854 spec->stream_digital_capture, in snd_hda_gen_build_pcms()
5855 spec->dig_in_nid); in snd_hda_gen_build_pcms()
5858 if (spec->no_analog) in snd_hda_gen_build_pcms()
5862 * model, configure a second analog capture-only PCM. in snd_hda_gen_build_pcms()
5864 have_multi_adcs = (spec->num_adc_nids > 1) && in snd_hda_gen_build_pcms()
5865 !spec->dyn_adc_switch && !spec->auto_mic; in snd_hda_gen_build_pcms()
5867 if (spec->alt_dac_nid || have_multi_adcs) { in snd_hda_gen_build_pcms()
5868 fill_pcm_stream_name(spec->stream_name_alt_analog, in snd_hda_gen_build_pcms()
5869 sizeof(spec->stream_name_alt_analog), in snd_hda_gen_build_pcms()
5870 " Alt Analog", codec->core.chip_name); in snd_hda_gen_build_pcms()
5872 spec->stream_name_alt_analog); in snd_hda_gen_build_pcms()
5874 return -ENOMEM; in snd_hda_gen_build_pcms()
5875 spec->pcm_rec[2] = info; in snd_hda_gen_build_pcms()
5876 if (spec->alt_dac_nid) in snd_hda_gen_build_pcms()
5877 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5879 spec->stream_analog_alt_playback, in snd_hda_gen_build_pcms()
5880 spec->alt_dac_nid); in snd_hda_gen_build_pcms()
5882 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5885 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5887 spec->stream_analog_alt_capture, in snd_hda_gen_build_pcms()
5888 spec->adc_nids[1]); in snd_hda_gen_build_pcms()
5889 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = in snd_hda_gen_build_pcms()
5890 spec->num_adc_nids - 1; in snd_hda_gen_build_pcms()
5892 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5903 * Standard auto-parser initializations
5913 if (!path || !path->depth) in set_output_and_unmute()
5915 pin = path->path[path->depth - 1]; in set_output_and_unmute()
5917 snd_hda_activate_path(codec, path, path->active, in set_output_and_unmute()
5918 aamix_default(codec->spec)); in set_output_and_unmute()
5919 set_pin_eapd(codec, pin, path->active); in set_output_and_unmute()
5925 struct hda_gen_spec *spec = codec->spec; in init_multi_out()
5928 for (i = 0; i < spec->autocfg.line_outs; i++) in init_multi_out()
5929 set_output_and_unmute(codec, spec->out_paths[i]); in init_multi_out()
5944 struct hda_gen_spec *spec = codec->spec; in init_extra_out()
5946 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) in init_extra_out()
5947 __init_extra_out(codec, spec->autocfg.hp_outs, spec->hp_paths); in init_extra_out()
5948 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) in init_extra_out()
5949 __init_extra_out(codec, spec->autocfg.speaker_outs, in init_extra_out()
5950 spec->speaker_paths); in init_extra_out()
5953 /* initialize multi-io paths */
5956 struct hda_gen_spec *spec = codec->spec; in init_multi_io()
5959 for (i = 0; i < spec->multi_ios; i++) { in init_multi_io()
5960 hda_nid_t pin = spec->multi_io[i].pin; in init_multi_io()
5965 if (!spec->multi_io[i].ctl_in) in init_multi_io()
5966 spec->multi_io[i].ctl_in = in init_multi_io()
5968 snd_hda_activate_path(codec, path, path->active, in init_multi_io()
5975 struct hda_gen_spec *spec = codec->spec; in init_aamix_paths()
5977 if (!spec->have_aamix_ctl) in init_aamix_paths()
5981 update_aamix_paths(codec, spec->aamix_mode, spec->out_paths[0], in init_aamix_paths()
5982 spec->aamix_out_paths[0], in init_aamix_paths()
5983 spec->autocfg.line_out_type); in init_aamix_paths()
5984 update_aamix_paths(codec, spec->aamix_mode, spec->hp_paths[0], in init_aamix_paths()
5985 spec->aamix_out_paths[1], in init_aamix_paths()
5987 update_aamix_paths(codec, spec->aamix_mode, spec->speaker_paths[0], in init_aamix_paths()
5988 spec->aamix_out_paths[2], in init_aamix_paths()
5995 struct hda_gen_spec *spec = codec->spec; in init_analog_input()
5996 struct auto_pin_cfg *cfg = &spec->autocfg; in init_analog_input() local
5999 for (i = 0; i < cfg->num_inputs; i++) { in init_analog_input()
6000 hda_nid_t nid = cfg->inputs[i].pin; in init_analog_input()
6005 if (spec->mixer_nid) { in init_analog_input()
6006 resume_path_from_idx(codec, spec->loopback_paths[i]); in init_analog_input()
6007 resume_path_from_idx(codec, spec->loopback_merge_path); in init_analog_input()
6015 struct hda_gen_spec *spec = codec->spec; in init_input_src()
6016 struct hda_input_mux *imux = &spec->input_mux; in init_input_src()
6020 if (spec->dyn_adc_switch) in init_input_src()
6023 nums = spec->num_adc_nids; in init_input_src()
6026 for (i = 0; i < imux->num_items; i++) { in init_input_src()
6029 bool active = path->active; in init_input_src()
6030 if (i == spec->cur_mux[c]) in init_input_src()
6035 if (spec->hp_mic) in init_input_src()
6039 if (spec->cap_sync_hook) in init_input_src()
6040 spec->cap_sync_hook(codec, NULL, NULL); in init_input_src()
6046 struct hda_gen_spec *spec = codec->spec; in init_digital()
6050 for (i = 0; i < spec->autocfg.dig_outs; i++) in init_digital()
6051 set_output_and_unmute(codec, spec->digout_paths[i]); in init_digital()
6052 pin = spec->autocfg.dig_in_pin; in init_digital()
6055 resume_path_from_idx(codec, spec->digin_path); in init_digital()
6059 /* clear unsol-event tags on unused pins; Conexant codecs seem to leave
6067 snd_array_for_each(&codec->init_pins, i, pin) { in clear_unsol_on_unused_pins()
6068 hda_nid_t nid = pin->nid; in clear_unsol_on_unused_pins()
6077 * snd_hda_gen_init - initialize the generic spec
6084 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_init()
6086 if (spec->init_hook) in snd_hda_gen_init()
6087 spec->init_hook(codec); in snd_hda_gen_init()
6089 if (!spec->skip_verbs) in snd_hda_gen_init()
6104 /* call init functions of standard auto-mute helpers */ in snd_hda_gen_init()
6109 if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook) in snd_hda_gen_init()
6110 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); in snd_hda_gen_init()
6118 * snd_hda_gen_free - free the generic spec
6126 snd_hda_gen_spec_free(codec->spec); in snd_hda_gen_free()
6127 kfree(codec->spec); in snd_hda_gen_free()
6128 codec->spec = NULL; in snd_hda_gen_free()
6133 * snd_hda_gen_reboot_notify - Make codec enter D3 before rebooting
6143 snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3); in snd_hda_gen_reboot_notify()
6144 snd_hda_codec_write(codec, codec->core.afg, 0, in snd_hda_gen_reboot_notify()
6152 * snd_hda_gen_check_power_status - check the loopback power save state
6160 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_check_power_status()
6161 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); in snd_hda_gen_check_power_status()
6184 * snd_hda_parse_generic_codec - Generic codec parser
6194 return -ENOMEM; in snd_hda_parse_generic_codec()
6196 codec->spec = spec; in snd_hda_parse_generic_codec()
6198 err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0); in snd_hda_parse_generic_codec()
6202 err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg); in snd_hda_parse_generic_codec()
6206 codec->patch_ops = generic_patch_ops; in snd_hda_parse_generic_codec()
6227 MODULE_DESCRIPTION("Generic HD-audio codec parser");