Lines Matching +full:pin +full:- +full:val
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()
108 int val; in parse_user_hints() local
110 val = snd_hda_get_bool_hint(codec, "jack_detect"); in parse_user_hints()
111 if (val >= 0) in parse_user_hints()
112 codec->no_jack_detect = !val; in parse_user_hints()
113 val = snd_hda_get_bool_hint(codec, "inv_jack_detect"); in parse_user_hints()
114 if (val >= 0) in parse_user_hints()
115 codec->inv_jack_detect = !!val; in parse_user_hints()
116 val = snd_hda_get_bool_hint(codec, "trigger_sense"); in parse_user_hints()
117 if (val >= 0) in parse_user_hints()
118 codec->no_trigger_sense = !val; in parse_user_hints()
119 val = snd_hda_get_bool_hint(codec, "inv_eapd"); in parse_user_hints()
120 if (val >= 0) in parse_user_hints()
121 codec->inv_eapd = !!val; in parse_user_hints()
122 val = snd_hda_get_bool_hint(codec, "pcm_format_first"); in parse_user_hints()
123 if (val >= 0) in parse_user_hints()
124 codec->pcm_format_first = !!val; in parse_user_hints()
125 val = snd_hda_get_bool_hint(codec, "sticky_stream"); in parse_user_hints()
126 if (val >= 0) in parse_user_hints()
127 codec->no_sticky_stream = !val; in parse_user_hints()
128 val = snd_hda_get_bool_hint(codec, "spdif_status_reset"); in parse_user_hints()
129 if (val >= 0) in parse_user_hints()
130 codec->spdif_status_reset = !!val; in parse_user_hints()
131 val = snd_hda_get_bool_hint(codec, "pin_amp_workaround"); in parse_user_hints()
132 if (val >= 0) in parse_user_hints()
133 codec->pin_amp_workaround = !!val; in parse_user_hints()
134 val = snd_hda_get_bool_hint(codec, "single_adc_amp"); in parse_user_hints()
135 if (val >= 0) in parse_user_hints()
136 codec->single_adc_amp = !!val; in parse_user_hints()
137 val = snd_hda_get_bool_hint(codec, "power_save_node"); in parse_user_hints()
138 if (val >= 0) in parse_user_hints()
139 codec->power_save_node = !!val; in parse_user_hints()
141 val = snd_hda_get_bool_hint(codec, "auto_mute"); in parse_user_hints()
142 if (val >= 0) in parse_user_hints()
143 spec->suppress_auto_mute = !val; in parse_user_hints()
144 val = snd_hda_get_bool_hint(codec, "auto_mic"); in parse_user_hints()
145 if (val >= 0) in parse_user_hints()
146 spec->suppress_auto_mic = !val; in parse_user_hints()
147 val = snd_hda_get_bool_hint(codec, "line_in_auto_switch"); in parse_user_hints()
148 if (val >= 0) in parse_user_hints()
149 spec->line_in_auto_switch = !!val; in parse_user_hints()
150 val = snd_hda_get_bool_hint(codec, "auto_mute_via_amp"); in parse_user_hints()
151 if (val >= 0) in parse_user_hints()
152 spec->auto_mute_via_amp = !!val; in parse_user_hints()
153 val = snd_hda_get_bool_hint(codec, "need_dac_fix"); in parse_user_hints()
154 if (val >= 0) in parse_user_hints()
155 spec->need_dac_fix = !!val; in parse_user_hints()
156 val = snd_hda_get_bool_hint(codec, "primary_hp"); in parse_user_hints()
157 if (val >= 0) in parse_user_hints()
158 spec->no_primary_hp = !val; in parse_user_hints()
159 val = snd_hda_get_bool_hint(codec, "multi_io"); in parse_user_hints()
160 if (val >= 0) in parse_user_hints()
161 spec->no_multi_io = !val; in parse_user_hints()
162 val = snd_hda_get_bool_hint(codec, "multi_cap_vol"); in parse_user_hints()
163 if (val >= 0) in parse_user_hints()
164 spec->multi_cap_vol = !!val; in parse_user_hints()
165 val = snd_hda_get_bool_hint(codec, "inv_dmic_split"); in parse_user_hints()
166 if (val >= 0) in parse_user_hints()
167 spec->inv_dmic_split = !!val; in parse_user_hints()
168 val = snd_hda_get_bool_hint(codec, "indep_hp"); in parse_user_hints()
169 if (val >= 0) in parse_user_hints()
170 spec->indep_hp = !!val; in parse_user_hints()
171 val = snd_hda_get_bool_hint(codec, "add_stereo_mix_input"); in parse_user_hints()
172 if (val >= 0) in parse_user_hints()
173 spec->add_stereo_mix_input = !!val; in parse_user_hints()
175 val = snd_hda_get_bool_hint(codec, "add_out_jack_modes"); in parse_user_hints()
176 if (val >= 0) in parse_user_hints()
177 spec->add_jack_modes = !!val; in parse_user_hints()
178 val = snd_hda_get_bool_hint(codec, "add_in_jack_modes"); in parse_user_hints()
179 if (val >= 0) in parse_user_hints()
180 spec->add_jack_modes = !!val; in parse_user_hints()
181 val = snd_hda_get_bool_hint(codec, "add_jack_modes"); in parse_user_hints()
182 if (val >= 0) in parse_user_hints()
183 spec->add_jack_modes = !!val; in parse_user_hints()
184 val = snd_hda_get_bool_hint(codec, "power_down_unused"); in parse_user_hints()
185 if (val >= 0) in parse_user_hints()
186 spec->power_down_unused = !!val; in parse_user_hints()
187 val = snd_hda_get_bool_hint(codec, "add_hp_mic"); in parse_user_hints()
188 if (val >= 0) in parse_user_hints()
189 spec->hp_mic = !!val; in parse_user_hints()
190 val = snd_hda_get_bool_hint(codec, "hp_mic_detect"); in parse_user_hints()
191 if (val >= 0) in parse_user_hints()
192 spec->suppress_hp_mic_detect = !val; in parse_user_hints()
193 val = snd_hda_get_bool_hint(codec, "vmaster"); in parse_user_hints()
194 if (val >= 0) in parse_user_hints()
195 spec->suppress_vmaster = !val; in parse_user_hints()
197 if (!snd_hda_get_int_hint(codec, "mixer_nid", &val)) in parse_user_hints()
198 spec->mixer_nid = val; in parse_user_hints()
202 * pin control value accesses
205 #define update_pin_ctl(codec, pin, val) \ argument
206 snd_hda_codec_write_cache(codec, pin, 0, \
207 AC_VERB_SET_PIN_WIDGET_CONTROL, val)
210 static inline void restore_pin_ctl(struct hda_codec *codec, hda_nid_t pin) in restore_pin_ctl() argument
212 update_pin_ctl(codec, pin, snd_hda_codec_get_pin_target(codec, pin)); in restore_pin_ctl()
216 static void set_pin_target(struct hda_codec *codec, hda_nid_t pin, in set_pin_target() argument
217 unsigned int val, bool do_write) in set_pin_target() argument
219 if (!pin) in set_pin_target()
221 val = snd_hda_correct_pin_ctl(codec, pin, val); in set_pin_target()
222 snd_hda_codec_set_pin_target(codec, pin, val); in set_pin_target()
224 update_pin_ctl(codec, pin, val); in set_pin_target()
229 hda_nid_t *pins, unsigned int val) in set_pin_targets() argument
233 set_pin_target(codec, pins[i], val, false); in set_pin_targets()
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()
345 static bool is_ctl_used(struct hda_codec *codec, unsigned int val, int type) in is_ctl_used() argument
347 struct hda_gen_spec *spec = codec->spec; in is_ctl_used()
351 val &= AMP_VAL_COMPARE_MASK; 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()
363 unsigned int val = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir); in is_ctl_associated() local
364 return is_ctl_used(codec, val, type); in is_ctl_associated()
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()
512 /* return a DAC if paired to the given pin by codec driver */
513 static hda_nid_t get_preferred_dac(struct hda_codec *codec, hda_nid_t pin) in get_preferred_dac() argument
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()
521 if (*list == pin) in get_preferred_dac()
527 static hda_nid_t look_for_dac(struct hda_codec *codec, hda_nid_t pin, in look_for_dac() argument
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()
541 if (is_reachable_path(codec, nid, pin)) in look_for_dac()
548 static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs) in amp_val_replace_channels() argument
550 val &= ~(0x3U << 16); in amp_val_replace_channels()
551 val |= chs << 16; in amp_val_replace_channels()
552 return val; in amp_val_replace_channels()
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)
672 unsigned int val = 0; in get_amp_val_to_activate() local
677 val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; in get_amp_val_to_activate()
681 val |= HDA_AMP_MUTE; in get_amp_val_to_activate()
683 return val; in get_amp_val_to_activate()
686 /* is this a stereo widget or a stereo-to-mono mix? */
707 int val = get_amp_val_to_activate(codec, nid, dir, caps, false); in init_amp() local
710 snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); in init_amp()
712 snd_hda_codec_amp_init(codec, nid, 0, dir, idx, 0xff, val); in init_amp()
717 unsigned int mask, unsigned int val) in update_amp() argument
721 mask, val); in update_amp()
724 mask, val); in update_amp()
752 unsigned int mask, val; in activate_amp() local
755 val = get_amp_val_to_activate(codec, nid, dir, caps, enable); in activate_amp()
760 val &= mask; in activate_amp()
761 update_amp(codec, nid, dir, idx, mask, val); in activate_amp()
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()
916 /* turn on/off EAPD on the given pin */
917 static void set_pin_eapd(struct hda_codec *codec, hda_nid_t pin, bool enable) in set_pin_eapd() argument
919 struct hda_gen_spec *spec = codec->spec; in set_pin_eapd()
920 if (spec->own_eapd_ctl || in set_pin_eapd()
921 !(snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD)) in set_pin_eapd()
923 if (spec->keep_eapd_on && !enable) in set_pin_eapd()
925 if (codec->inv_eapd) in set_pin_eapd()
927 snd_hda_codec_write_cache(codec, pin, 0, 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()
980 int cidx, unsigned long val) in add_control() argument
987 knew->index = cidx; in add_control()
988 if (get_amp_nid_(val)) in add_control()
989 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in add_control()
990 if (knew->access == 0) in add_control()
991 knew->access = SNDRV_CTL_ELEM_ACCESS_READWRITE; in add_control()
992 knew->private_value = val; in add_control()
998 const char *sfx, int cidx, unsigned long val) in add_control_with_pfx() argument
1005 return -EINVAL; in add_control_with_pfx()
1006 if (!add_control(spec, type, name, cidx, val)) in add_control_with_pfx()
1007 return -ENOMEM; in add_control_with_pfx()
1011 #define add_pb_vol_ctrl(spec, type, pfx, val) \ argument
1012 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
1013 #define add_pb_sw_ctrl(spec, type, pfx, val) \ argument
1014 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
1015 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ argument
1016 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
1017 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ argument
1018 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
1023 unsigned int val; in add_vol_ctl() local
1026 val = path->ctls[NID_PATH_VOL_CTL]; in add_vol_ctl()
1027 if (!val) in add_vol_ctl()
1029 val = amp_val_replace_channels(val, chs); in add_vol_ctl()
1030 return __add_pb_vol_ctrl(codec->spec, HDA_CTL_WIDGET_VOL, pfx, cidx, val); in add_vol_ctl()
1033 /* return the channel bits suitable for the given path->ctls[] */
1039 hda_nid_t nid = get_amp_nid_(path->ctls[type]); in get_default_ch_nums()
1053 /* create a mute-switch for the given mixer widget;
1054 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
1059 unsigned int val; in add_sw_ctl() local
1064 val = path->ctls[NID_PATH_MUTE_CTL]; in add_sw_ctl()
1065 if (!val) in add_sw_ctl()
1067 val = amp_val_replace_channels(val, chs); in add_sw_ctl()
1068 if (get_amp_direction_(val) == HDA_INPUT) { in add_sw_ctl()
1069 hda_nid_t nid = get_amp_nid_(val); in add_sw_ctl()
1073 val |= nums << 19; in add_sw_ctl()
1076 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); in add_sw_ctl()
1091 struct hda_gen_spec *spec = codec->spec; in sync_auto_mute_bits()
1093 if (spec->auto_mute_via_amp) { in sync_auto_mute_bits()
1095 bool enabled = !((spec->mute_bits >> nid) & 1); in sync_auto_mute_bits()
1096 ucontrol->value.integer.value[0] &= enabled; in sync_auto_mute_bits()
1097 ucontrol->value.integer.value[1] &= enabled; in sync_auto_mute_bits()
1121 mutex_lock(&codec->control_mutex); in hda_gen_bind_mute_get()
1122 pval = kcontrol->private_value; in hda_gen_bind_mute_get()
1123 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ in hda_gen_bind_mute_get()
1125 kcontrol->private_value = pval; in hda_gen_bind_mute_get()
1126 mutex_unlock(&codec->control_mutex); in hda_gen_bind_mute_get()
1139 mutex_lock(&codec->control_mutex); in hda_gen_bind_mute_put()
1140 pval = kcontrol->private_value; in hda_gen_bind_mute_put()
1143 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | in hda_gen_bind_mute_put()
1150 kcontrol->private_value = pval; in hda_gen_bind_mute_put()
1151 mutex_unlock(&codec->control_mutex); in hda_gen_bind_mute_put()
1159 return path && path->ctls[ctl_type]; in path_has_mixer()
1170 struct hda_gen_spec *spec = codec->spec; in get_line_out_pfx()
1171 struct auto_pin_cfg *cfg = &spec->autocfg; in get_line_out_pfx()
1174 if (cfg->line_outs == 1 && !spec->multi_ios && in get_line_out_pfx()
1175 !codec->force_pin_prefix && in get_line_out_pfx()
1176 !cfg->hp_outs && !cfg->speaker_outs) in get_line_out_pfx()
1177 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1182 if (spec->multiout.num_dacs == 1 && !spec->mixer_nid && in get_line_out_pfx()
1183 !codec->force_pin_prefix && in get_line_out_pfx()
1184 !spec->multiout.hp_out_nid[0] && !spec->multiout.extra_out_nid[0]) in get_line_out_pfx()
1185 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1187 /* multi-io channels */ in get_line_out_pfx()
1188 if (ch >= cfg->line_outs) in get_line_out_pfx()
1191 switch (cfg->line_out_type) { in get_line_out_pfx()
1196 if (!ch && cfg->hp_outs && in get_line_out_pfx()
1197 !path_has_mixer(codec, spec->hp_paths[0], ctl_type)) in get_line_out_pfx()
1199 if (cfg->line_outs == 1) in get_line_out_pfx()
1201 if (cfg->line_outs == 2) in get_line_out_pfx()
1208 if (!ch && cfg->speaker_outs && in get_line_out_pfx()
1209 !path_has_mixer(codec, spec->speaker_paths[0], ctl_type)) in get_line_out_pfx()
1211 /* for multi-io case, only the primary out */ in get_line_out_pfx()
1212 if (ch && spec->multi_ios) in get_line_out_pfx()
1223 if (cfg->speaker_outs) in get_line_out_pfx()
1225 spec->speaker_paths[0], ctl_type); in get_line_out_pfx()
1226 if (cfg->hp_outs) in get_line_out_pfx()
1227 hp_lo_shared = !path_has_mixer(codec, spec->hp_paths[0], ctl_type); in get_line_out_pfx()
1229 return spec->vmaster_mute.hook ? "PCM" : "Master"; in get_line_out_pfx()
1238 if (cfg->line_outs == 1 && !spec->multi_ios) in get_line_out_pfx()
1260 /* No possible multi-ios */
1287 struct hda_gen_spec *spec = codec->spec; in assign_out_path_ctls()
1289 unsigned int val; in assign_out_path_ctls() local
1295 if (path->ctls[NID_PATH_VOL_CTL] || in assign_out_path_ctls()
1296 path->ctls[NID_PATH_MUTE_CTL]) in assign_out_path_ctls()
1301 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); in assign_out_path_ctls()
1302 if (spec->dac_min_mute) in assign_out_path_ctls()
1303 val |= HDA_AMP_VAL_MIN_MUTE; in assign_out_path_ctls()
1304 if (is_ctl_used(codec, val, NID_PATH_VOL_CTL)) in assign_out_path_ctls()
1307 path->ctls[NID_PATH_VOL_CTL] = val; in assign_out_path_ctls()
1315 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); in assign_out_path_ctls()
1317 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); in assign_out_path_ctls()
1318 if (is_ctl_used(codec, val, NID_PATH_MUTE_CTL)) in assign_out_path_ctls()
1321 path->ctls[NID_PATH_MUTE_CTL] = val; in assign_out_path_ctls()
1350 struct hda_gen_spec *spec = codec->spec; in get_primary_out()
1351 struct auto_pin_cfg *cfg = &spec->autocfg; in get_primary_out()
1353 if (cfg->line_outs > idx) in get_primary_out()
1354 return spec->private_dac_nids[idx]; in get_primary_out()
1355 idx -= cfg->line_outs; in get_primary_out()
1356 if (spec->multi_ios > idx) in get_primary_out()
1357 return spec->multi_io[idx].dac; in get_primary_out()
1363 hda_nid_t dac, hda_nid_t pin) in try_dac() argument
1365 return is_reachable_path(codec, dac, pin) ? dac : 0; in try_dac()
1374 struct hda_gen_spec *spec = codec->spec; in try_assign_dacs()
1384 hda_nid_t pin = pins[i]; in try_assign_dacs() local
1386 if (!spec->preferred_dacs) { in try_assign_dacs()
1394 dacs[i] = get_preferred_dac(codec, pin); in try_assign_dacs()
1397 badness += bad->shared_primary; in try_assign_dacs()
1398 } else if (spec->preferred_dacs) { in try_assign_dacs()
1403 dacs[i] = look_for_dac(codec, pin, false); in try_assign_dacs()
1407 if (is_reachable_path(codec, dacs[j], pin)) { in try_assign_dacs()
1419 dac = try_dac(codec, get_primary_out(codec, i), pin); in try_assign_dacs()
1421 dac = try_dac(codec, dacs[0], pin); in try_assign_dacs()
1423 dac = try_dac(codec, get_primary_out(codec, i), pin); in try_assign_dacs()
1426 badness += bad->shared_primary; in try_assign_dacs()
1428 badness += bad->shared_surr; in try_assign_dacs()
1430 badness += bad->shared_clfe; in try_assign_dacs()
1431 } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { in try_assign_dacs()
1432 dac = spec->private_dac_nids[0]; in try_assign_dacs()
1433 badness += bad->shared_surr_main; in try_assign_dacs()
1435 badness += bad->no_primary_dac; in try_assign_dacs()
1437 badness += bad->no_dac; in try_assign_dacs()
1441 path = snd_hda_add_new_path(codec, dac, pin, -spec->mixer_nid); in try_assign_dacs()
1442 if (!path && !i && spec->mixer_nid) { in try_assign_dacs()
1444 path = snd_hda_add_new_path(codec, dac, pin, 0); in try_assign_dacs()
1448 badness += bad->no_dac; in try_assign_dacs()
1451 path->active = true; in try_assign_dacs()
1460 /* return NID if the given pin has only a single connection to a certain DAC */
1461 static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) in get_dac_if_single() argument
1463 struct hda_gen_spec *spec = codec->spec; in get_dac_if_single()
1467 for (i = 0; i < spec->num_all_dacs; i++) { in get_dac_if_single()
1468 hda_nid_t nid = spec->all_dacs[i]; in get_dac_if_single()
1471 if (is_reachable_path(codec, nid, pin)) { in get_dac_if_single()
1480 /* check whether the given pin can be a multi-io pin */
1497 /* count the number of input pins that are capable to be multi-io */
1500 struct hda_gen_spec *spec = codec->spec; in count_multiio_pins()
1501 struct auto_pin_cfg *cfg = &spec->autocfg; in count_multiio_pins()
1507 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { in count_multiio_pins()
1508 for (i = 0; i < cfg->num_inputs; i++) { in count_multiio_pins()
1509 if (cfg->inputs[i].type != type) in count_multiio_pins()
1512 cfg->inputs[i].pin)) in count_multiio_pins()
1520 * multi-io helper
1523 * zero if any pins are filled, non-zero if nothing found.
1531 struct hda_gen_spec *spec = codec->spec; in fill_multi_ios()
1532 struct auto_pin_cfg *cfg = &spec->autocfg; in fill_multi_ios()
1539 old_pins = spec->multi_ios; in fill_multi_ios()
1547 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { in fill_multi_ios()
1548 for (i = 0; i < cfg->num_inputs; i++) { in fill_multi_ios()
1549 hda_nid_t nid = cfg->inputs[i].pin; in fill_multi_ios()
1552 if (cfg->inputs[i].type != type) in fill_multi_ios()
1556 for (j = 0; j < spec->multi_ios; j++) { in fill_multi_ios()
1557 if (nid == spec->multi_io[j].pin) in fill_multi_ios()
1560 if (j < spec->multi_ios) in fill_multi_ios()
1572 -spec->mixer_nid); in fill_multi_ios()
1578 spec->multi_io[spec->multi_ios].pin = nid; in fill_multi_ios()
1579 spec->multi_io[spec->multi_ios].dac = dac; in fill_multi_ios()
1580 spec->out_paths[cfg->line_outs + spec->multi_ios] = in fill_multi_ios()
1582 spec->multi_ios++; in fill_multi_ios()
1583 if (spec->multi_ios >= 2) in fill_multi_ios()
1590 if (old_pins == spec->multi_ios) { in fill_multi_ios()
1596 if (!hardwired && spec->multi_ios < 2) { in fill_multi_ios()
1598 spec->paths.used -= spec->multi_ios - old_pins; in fill_multi_ios()
1599 spec->multi_ios = old_pins; in fill_multi_ios()
1604 for (i = old_pins; i < spec->multi_ios; i++) { in fill_multi_ios()
1605 path = snd_hda_get_path_from_idx(codec, spec->out_paths[cfg->line_outs + i]); in fill_multi_ios()
1616 struct hda_gen_spec *spec = codec->spec; in map_singles()
1628 -spec->mixer_nid); in map_singles()
1629 if (!path && !i && spec->mixer_nid) in map_singles()
1635 path->active = true; in map_singles()
1644 return spec->aamix_out_paths[0] || spec->aamix_out_paths[1] || in has_aamix_out_paths()
1645 spec->aamix_out_paths[2]; in has_aamix_out_paths()
1651 struct hda_gen_spec *spec = codec->spec; in check_aamix_out_path()
1653 hda_nid_t path_dac, dac, pin; in check_aamix_out_path() local
1656 if (!path || !path->depth || in check_aamix_out_path()
1657 is_nid_contained(path, spec->mixer_nid)) in check_aamix_out_path()
1659 path_dac = path->path[0]; in check_aamix_out_path()
1660 dac = spec->private_dac_nids[0]; in check_aamix_out_path()
1661 pin = path->path[path->depth - 1]; in check_aamix_out_path()
1662 path = snd_hda_add_new_path(codec, dac, pin, spec->mixer_nid); in check_aamix_out_path()
1666 else if (spec->multiout.hp_out_nid[0]) in check_aamix_out_path()
1667 dac = spec->multiout.hp_out_nid[0]; in check_aamix_out_path()
1668 else if (spec->multiout.extra_out_nid[0]) in check_aamix_out_path()
1669 dac = spec->multiout.extra_out_nid[0]; in check_aamix_out_path()
1673 path = snd_hda_add_new_path(codec, dac, pin, in check_aamix_out_path()
1674 spec->mixer_nid); in check_aamix_out_path()
1678 /* print_nid_path(codec, "output-aamix", path); */ in check_aamix_out_path()
1679 path->active = false; /* unused as default */ in check_aamix_out_path()
1680 path->pin_fixed = true; /* static route */ in check_aamix_out_path()
1687 struct hda_gen_spec *spec = codec->spec; in indep_hp_possible()
1688 struct auto_pin_cfg *cfg = &spec->autocfg; in indep_hp_possible()
1692 if (cfg->line_out_type == AUTO_PIN_HP_OUT) in indep_hp_possible()
1693 idx = spec->out_paths[0]; in indep_hp_possible()
1695 idx = spec->hp_paths[0]; in indep_hp_possible()
1701 if (!spec->mixer_nid || !is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1705 for (i = 0; i < cfg->line_outs; i++) { in indep_hp_possible()
1706 if (spec->out_paths[i] == idx) in indep_hp_possible()
1708 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); in indep_hp_possible()
1709 if (path && is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1712 for (i = 0; i < cfg->speaker_outs; i++) { in indep_hp_possible()
1713 path = snd_hda_get_path_from_idx(codec, spec->speaker_paths[i]); in indep_hp_possible()
1714 if (path && is_nid_contained(path, spec->mixer_nid)) in indep_hp_possible()
1736 dacs[i] = path->path[0]; in refill_shared_dacs()
1740 /* fill in the dac_nids table from the parsed pin configuration */
1745 struct hda_gen_spec *spec = codec->spec; in fill_and_eval_dacs()
1746 struct auto_pin_cfg *cfg = &spec->autocfg; in fill_and_eval_dacs()
1750 spec->multiout.num_dacs = cfg->line_outs; in fill_and_eval_dacs()
1751 spec->multiout.dac_nids = spec->private_dac_nids; in fill_and_eval_dacs()
1752 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); in fill_and_eval_dacs()
1753 memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); in fill_and_eval_dacs()
1754 memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid)); in fill_and_eval_dacs()
1755 spec->multi_ios = 0; in fill_and_eval_dacs()
1756 snd_array_free(&spec->paths); in fill_and_eval_dacs()
1759 memset(spec->out_paths, 0, sizeof(spec->out_paths)); in fill_and_eval_dacs()
1760 memset(spec->hp_paths, 0, sizeof(spec->hp_paths)); in fill_and_eval_dacs()
1761 memset(spec->speaker_paths, 0, sizeof(spec->speaker_paths)); in fill_and_eval_dacs()
1762 memset(spec->aamix_out_paths, 0, sizeof(spec->aamix_out_paths)); in fill_and_eval_dacs()
1763 memset(spec->digout_paths, 0, sizeof(spec->digout_paths)); in fill_and_eval_dacs()
1764 memset(spec->input_paths, 0, sizeof(spec->input_paths)); in fill_and_eval_dacs()
1765 memset(spec->loopback_paths, 0, sizeof(spec->loopback_paths)); in fill_and_eval_dacs()
1766 memset(&spec->digin_path, 0, sizeof(spec->digin_path)); in fill_and_eval_dacs()
1770 /* fill hard-wired DACs first */ in fill_and_eval_dacs()
1774 mapped = map_singles(codec, cfg->line_outs, in fill_and_eval_dacs()
1775 cfg->line_out_pins, in fill_and_eval_dacs()
1776 spec->private_dac_nids, in fill_and_eval_dacs()
1777 spec->out_paths); in fill_and_eval_dacs()
1778 mapped |= map_singles(codec, cfg->hp_outs, in fill_and_eval_dacs()
1779 cfg->hp_pins, in fill_and_eval_dacs()
1780 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1781 spec->hp_paths); in fill_and_eval_dacs()
1782 mapped |= map_singles(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1783 cfg->speaker_pins, in fill_and_eval_dacs()
1784 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1785 spec->speaker_paths); in fill_and_eval_dacs()
1786 if (!spec->no_multi_io && in fill_and_eval_dacs()
1787 fill_mio_first && cfg->line_outs == 1 && in fill_and_eval_dacs()
1788 cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1789 err = fill_multi_ios(codec, cfg->line_out_pins[0], true); in fill_and_eval_dacs()
1796 badness += try_assign_dacs(codec, cfg->line_outs, cfg->line_out_pins, in fill_and_eval_dacs()
1797 spec->private_dac_nids, spec->out_paths, in fill_and_eval_dacs()
1798 spec->main_out_badness); in fill_and_eval_dacs()
1800 if (!spec->no_multi_io && fill_mio_first && in fill_and_eval_dacs()
1801 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1802 /* try to fill multi-io first */ in fill_and_eval_dacs()
1803 err = fill_multi_ios(codec, cfg->line_out_pins[0], false); in fill_and_eval_dacs()
1809 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in fill_and_eval_dacs()
1810 err = try_assign_dacs(codec, cfg->hp_outs, cfg->hp_pins, in fill_and_eval_dacs()
1811 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1812 spec->hp_paths, in fill_and_eval_dacs()
1813 spec->extra_out_badness); in fill_and_eval_dacs()
1818 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1819 err = try_assign_dacs(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1820 cfg->speaker_pins, in fill_and_eval_dacs()
1821 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1822 spec->speaker_paths, in fill_and_eval_dacs()
1823 spec->extra_out_badness); in fill_and_eval_dacs()
1828 if (!spec->no_multi_io && in fill_and_eval_dacs()
1829 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in fill_and_eval_dacs()
1830 err = fill_multi_ios(codec, cfg->line_out_pins[0], false); in fill_and_eval_dacs()
1836 if (spec->mixer_nid) { in fill_and_eval_dacs()
1837 spec->aamix_out_paths[0] = in fill_and_eval_dacs()
1838 check_aamix_out_path(codec, spec->out_paths[0]); in fill_and_eval_dacs()
1839 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in fill_and_eval_dacs()
1840 spec->aamix_out_paths[1] = in fill_and_eval_dacs()
1841 check_aamix_out_path(codec, spec->hp_paths[0]); in fill_and_eval_dacs()
1842 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1843 spec->aamix_out_paths[2] = in fill_and_eval_dacs()
1844 check_aamix_out_path(codec, spec->speaker_paths[0]); in fill_and_eval_dacs()
1847 if (!spec->no_multi_io && in fill_and_eval_dacs()
1848 cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1849 if (count_multiio_pins(codec, cfg->hp_pins[0]) >= 2) in fill_and_eval_dacs()
1850 spec->multi_ios = 1; /* give badness */ in fill_and_eval_dacs()
1852 /* re-count num_dacs and squash invalid entries */ in fill_and_eval_dacs()
1853 spec->multiout.num_dacs = 0; in fill_and_eval_dacs()
1854 for (i = 0; i < cfg->line_outs; i++) { in fill_and_eval_dacs()
1855 if (spec->private_dac_nids[i]) in fill_and_eval_dacs()
1856 spec->multiout.num_dacs++; in fill_and_eval_dacs()
1858 memmove(spec->private_dac_nids + i, in fill_and_eval_dacs()
1859 spec->private_dac_nids + i + 1, in fill_and_eval_dacs()
1860 sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); in fill_and_eval_dacs()
1861 spec->private_dac_nids[cfg->line_outs - 1] = 0; in fill_and_eval_dacs()
1865 spec->ext_channel_count = spec->min_channel_count = in fill_and_eval_dacs()
1866 spec->multiout.num_dacs * 2; in fill_and_eval_dacs()
1868 if (spec->multi_ios == 2) { in fill_and_eval_dacs()
1870 spec->private_dac_nids[spec->multiout.num_dacs++] = in fill_and_eval_dacs()
1871 spec->multi_io[i].dac; in fill_and_eval_dacs()
1872 } else if (spec->multi_ios) { in fill_and_eval_dacs()
1873 spec->multi_ios = 0; in fill_and_eval_dacs()
1877 if (spec->indep_hp && !indep_hp_possible(codec)) in fill_and_eval_dacs()
1880 /* re-fill the shared DAC for speaker / headphone */ in fill_and_eval_dacs()
1881 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in fill_and_eval_dacs()
1882 refill_shared_dacs(codec, cfg->hp_outs, in fill_and_eval_dacs()
1883 spec->multiout.hp_out_nid, in fill_and_eval_dacs()
1884 spec->hp_paths); in fill_and_eval_dacs()
1885 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in fill_and_eval_dacs()
1886 refill_shared_dacs(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1887 spec->multiout.extra_out_nid, in fill_and_eval_dacs()
1888 spec->speaker_paths); in fill_and_eval_dacs()
1917 struct hda_gen_spec *spec = codec->spec; in debug_show_configs()
1922 cfg->line_out_pins[0], cfg->line_out_pins[1], in debug_show_configs()
1923 cfg->line_out_pins[2], cfg->line_out_pins[3], in debug_show_configs()
1924 spec->multiout.dac_nids[0], in debug_show_configs()
1925 spec->multiout.dac_nids[1], in debug_show_configs()
1926 spec->multiout.dac_nids[2], in debug_show_configs()
1927 spec->multiout.dac_nids[3], in debug_show_configs()
1928 lo_type[cfg->line_out_type]); in debug_show_configs()
1929 for (i = 0; i < cfg->line_outs; i++) in debug_show_configs()
1930 print_nid_path_idx(codec, " out", spec->out_paths[i]); in debug_show_configs()
1931 if (spec->multi_ios > 0) in debug_show_configs()
1933 spec->multi_ios, in debug_show_configs()
1934 spec->multi_io[0].pin, spec->multi_io[1].pin, in debug_show_configs()
1935 spec->multi_io[0].dac, spec->multi_io[1].dac); in debug_show_configs()
1936 for (i = 0; i < spec->multi_ios; i++) in debug_show_configs()
1938 spec->out_paths[cfg->line_outs + i]); in debug_show_configs()
1939 if (cfg->hp_outs) in debug_show_configs()
1941 cfg->hp_pins[0], cfg->hp_pins[1], in debug_show_configs()
1942 cfg->hp_pins[2], cfg->hp_pins[3], in debug_show_configs()
1943 spec->multiout.hp_out_nid[0], in debug_show_configs()
1944 spec->multiout.hp_out_nid[1], in debug_show_configs()
1945 spec->multiout.hp_out_nid[2], in debug_show_configs()
1946 spec->multiout.hp_out_nid[3]); in debug_show_configs()
1947 for (i = 0; i < cfg->hp_outs; i++) in debug_show_configs()
1948 print_nid_path_idx(codec, " hp ", spec->hp_paths[i]); in debug_show_configs()
1949 if (cfg->speaker_outs) in debug_show_configs()
1951 cfg->speaker_pins[0], cfg->speaker_pins[1], in debug_show_configs()
1952 cfg->speaker_pins[2], cfg->speaker_pins[3], in debug_show_configs()
1953 spec->multiout.extra_out_nid[0], in debug_show_configs()
1954 spec->multiout.extra_out_nid[1], in debug_show_configs()
1955 spec->multiout.extra_out_nid[2], in debug_show_configs()
1956 spec->multiout.extra_out_nid[3]); in debug_show_configs()
1957 for (i = 0; i < cfg->speaker_outs; i++) in debug_show_configs()
1958 print_nid_path_idx(codec, " spk", spec->speaker_paths[i]); in debug_show_configs()
1960 print_nid_path_idx(codec, " mix", spec->aamix_out_paths[i]); in debug_show_configs()
1969 struct hda_gen_spec *spec = codec->spec; in fill_all_dac_nids()
1972 spec->num_all_dacs = 0; in fill_all_dac_nids()
1973 memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); in fill_all_dac_nids()
1977 if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { in fill_all_dac_nids()
1981 spec->all_dacs[spec->num_all_dacs++] = nid; in fill_all_dac_nids()
1987 struct hda_gen_spec *spec = codec->spec; in parse_output_paths()
1988 struct auto_pin_cfg *cfg = &spec->autocfg; in parse_output_paths()
1990 unsigned int val; in parse_output_paths() local
1999 return -ENOMEM; in parse_output_paths()
2010 cfg->line_out_type, fill_hardwired, fill_mio_first, in parse_output_paths()
2030 if (cfg->speaker_outs > 0 && in parse_output_paths()
2031 cfg->line_out_type == AUTO_PIN_HP_OUT) { in parse_output_paths()
2032 cfg->hp_outs = cfg->line_outs; in parse_output_paths()
2033 memcpy(cfg->hp_pins, cfg->line_out_pins, in parse_output_paths()
2034 sizeof(cfg->hp_pins)); in parse_output_paths()
2035 cfg->line_outs = cfg->speaker_outs; in parse_output_paths()
2036 memcpy(cfg->line_out_pins, cfg->speaker_pins, in parse_output_paths()
2037 sizeof(cfg->speaker_pins)); in parse_output_paths()
2038 cfg->speaker_outs = 0; in parse_output_paths()
2039 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); in parse_output_paths()
2040 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; in parse_output_paths()
2044 if (cfg->hp_outs > 0 && in parse_output_paths()
2045 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { in parse_output_paths()
2046 cfg->speaker_outs = cfg->line_outs; in parse_output_paths()
2047 memcpy(cfg->speaker_pins, cfg->line_out_pins, in parse_output_paths()
2048 sizeof(cfg->speaker_pins)); in parse_output_paths()
2049 cfg->line_outs = cfg->hp_outs; in parse_output_paths()
2050 memcpy(cfg->line_out_pins, cfg->hp_pins, in parse_output_paths()
2051 sizeof(cfg->hp_pins)); in parse_output_paths()
2052 cfg->hp_outs = 0; in parse_output_paths()
2053 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); in parse_output_paths()
2054 cfg->line_out_type = AUTO_PIN_HP_OUT; in parse_output_paths()
2067 cfg->line_out_type, best_wired, best_mio); in parse_output_paths()
2070 if (cfg->line_out_pins[0]) { in parse_output_paths()
2072 path = snd_hda_get_path_from_idx(codec, spec->out_paths[0]); in parse_output_paths()
2074 spec->vmaster_nid = look_for_out_vol_nid(codec, path); in parse_output_paths()
2075 if (spec->vmaster_nid) { in parse_output_paths()
2076 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, in parse_output_paths()
2077 HDA_OUTPUT, spec->vmaster_tlv); in parse_output_paths()
2078 if (spec->dac_min_mute) in parse_output_paths()
2079 spec->vmaster_tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] |= TLV_DB_SCALE_MUTE; in parse_output_paths()
2084 if (spec->prefer_hp_amp || cfg->line_out_type == AUTO_PIN_HP_OUT) in parse_output_paths()
2085 val = PIN_HP; in parse_output_paths()
2087 val = PIN_OUT; in parse_output_paths()
2088 set_pin_targets(codec, cfg->line_outs, cfg->line_out_pins, val); in parse_output_paths()
2089 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in parse_output_paths()
2090 set_pin_targets(codec, cfg->hp_outs, cfg->hp_pins, PIN_HP); in parse_output_paths()
2091 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in parse_output_paths()
2092 val = spec->prefer_hp_amp ? PIN_HP : PIN_OUT; in parse_output_paths()
2093 set_pin_targets(codec, cfg->speaker_outs, in parse_output_paths()
2094 cfg->speaker_pins, val); in parse_output_paths()
2098 if (spec->indep_hp && !indep_hp_possible(codec)) in parse_output_paths()
2099 spec->indep_hp = 0; in parse_output_paths()
2109 struct hda_gen_spec *spec = codec->spec; in create_multi_out_ctls()
2112 noutputs = cfg->line_outs; in create_multi_out_ctls()
2113 if (spec->multi_ios > 0 && cfg->line_outs < 3) in create_multi_out_ctls()
2114 noutputs += spec->multi_ios; in create_multi_out_ctls()
2121 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); in create_multi_out_ctls()
2205 struct hda_gen_spec *spec = codec->spec; in create_hp_out_ctls()
2206 return create_extra_outs(codec, spec->autocfg.hp_outs, in create_hp_out_ctls()
2207 spec->hp_paths, in create_hp_out_ctls()
2213 struct hda_gen_spec *spec = codec->spec; in create_speaker_out_ctls()
2214 return create_extra_outs(codec, spec->autocfg.speaker_outs, in create_speaker_out_ctls()
2215 spec->speaker_paths, in create_speaker_out_ctls()
2235 struct hda_gen_spec *spec = codec->spec; in indep_hp_get()
2236 ucontrol->value.enumerated.item[0] = spec->indep_hp_enabled; in indep_hp_get()
2248 struct hda_gen_spec *spec = codec->spec; in indep_hp_put()
2249 unsigned int select = ucontrol->value.enumerated.item[0]; in indep_hp_put()
2252 mutex_lock(&spec->pcm_mutex); in indep_hp_put()
2253 if (spec->active_streams) { in indep_hp_put()
2254 ret = -EBUSY; in indep_hp_put()
2258 if (spec->indep_hp_enabled != select) { in indep_hp_put()
2260 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in indep_hp_put()
2261 dacp = &spec->private_dac_nids[0]; in indep_hp_put()
2263 dacp = &spec->multiout.hp_out_nid[0]; in indep_hp_put()
2266 if (spec->have_aamix_ctl) { in indep_hp_put()
2267 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in indep_hp_put()
2268 update_aamix_paths(codec, spec->aamix_mode, in indep_hp_put()
2269 spec->out_paths[0], in indep_hp_put()
2270 spec->aamix_out_paths[0], in indep_hp_put()
2271 spec->autocfg.line_out_type); in indep_hp_put()
2273 update_aamix_paths(codec, spec->aamix_mode, in indep_hp_put()
2274 spec->hp_paths[0], in indep_hp_put()
2275 spec->aamix_out_paths[1], in indep_hp_put()
2279 spec->indep_hp_enabled = select; in indep_hp_put()
2280 if (spec->indep_hp_enabled) in indep_hp_put()
2283 *dacp = spec->alt_dac_nid; in indep_hp_put()
2289 mutex_unlock(&spec->pcm_mutex); in indep_hp_put()
2304 struct hda_gen_spec *spec = codec->spec; in create_indep_hp_ctls()
2307 if (!spec->indep_hp) in create_indep_hp_ctls()
2309 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in create_indep_hp_ctls()
2310 dac = spec->multiout.dac_nids[0]; in create_indep_hp_ctls()
2312 dac = spec->multiout.hp_out_nid[0]; in create_indep_hp_ctls()
2314 spec->indep_hp = 0; in create_indep_hp_ctls()
2318 spec->indep_hp_enabled = false; in create_indep_hp_ctls()
2319 spec->alt_dac_nid = dac; in create_indep_hp_ctls()
2321 return -ENOMEM; in create_indep_hp_ctls()
2333 struct hda_gen_spec *spec = codec->spec; in ch_mode_info()
2336 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in ch_mode_info()
2337 uinfo->count = 1; in ch_mode_info()
2338 uinfo->value.enumerated.items = spec->multi_ios + 1; in ch_mode_info()
2339 if (uinfo->value.enumerated.item > spec->multi_ios) in ch_mode_info()
2340 uinfo->value.enumerated.item = spec->multi_ios; in ch_mode_info()
2341 chs = uinfo->value.enumerated.item * 2 + spec->min_channel_count; in ch_mode_info()
2342 sprintf(uinfo->value.enumerated.name, "%dch", chs); in ch_mode_info()
2350 struct hda_gen_spec *spec = codec->spec; in ch_mode_get()
2351 ucontrol->value.enumerated.item[0] = in ch_mode_get()
2352 (spec->ext_channel_count - spec->min_channel_count) / 2; in ch_mode_get()
2359 struct hda_gen_spec *spec = codec->spec; in get_multiio_path()
2361 spec->out_paths[spec->autocfg.line_outs + idx]); in get_multiio_path()
2371 return !spec->have_aamix_ctl || spec->aamix_mode; in aamix_default()
2376 struct hda_gen_spec *spec = codec->spec; in set_multi_io()
2377 hda_nid_t nid = spec->multi_io[idx].pin; in set_multi_io()
2382 return -EINVAL; in set_multi_io()
2384 if (path->active == output) in set_multi_io()
2394 set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true); in set_multi_io()
2408 struct hda_gen_spec *spec = codec->spec; in ch_mode_put()
2411 ch = ucontrol->value.enumerated.item[0]; in ch_mode_put()
2412 if (ch < 0 || ch > spec->multi_ios) in ch_mode_put()
2413 return -EINVAL; in ch_mode_put()
2414 if (ch == (spec->ext_channel_count - spec->min_channel_count) / 2) in ch_mode_put()
2416 spec->ext_channel_count = ch * 2 + spec->min_channel_count; in ch_mode_put()
2417 for (i = 0; i < spec->multi_ios; i++) in ch_mode_put()
2419 spec->multiout.max_channels = max(spec->ext_channel_count, in ch_mode_put()
2420 spec->const_channel_count); in ch_mode_put()
2421 if (spec->need_dac_fix) in ch_mode_put()
2422 spec->multiout.num_dacs = spec->multiout.max_channels / 2; in ch_mode_put()
2436 struct hda_gen_spec *spec = codec->spec; in create_multi_channel_mode()
2438 if (spec->multi_ios > 0) { in create_multi_channel_mode()
2440 return -ENOMEM; in create_multi_channel_mode()
2455 struct hda_gen_spec *spec = codec->spec; in loopback_mixing_get()
2456 ucontrol->value.enumerated.item[0] = spec->aamix_mode; in loopback_mixing_get()
2464 struct hda_gen_spec *spec = codec->spec; in update_aamix_paths()
2475 if (out_type == AUTO_PIN_HP_OUT && spec->indep_hp_enabled && in update_aamix_paths()
2476 mix_path->path[0] != spec->alt_dac_nid) in update_aamix_paths()
2490 /* re-initialize the output paths; only called from loopback_mixing_put() */
2494 struct hda_gen_spec *spec = codec->spec; in update_output_paths()
2501 snd_hda_activate_path(codec, path, path->active, in update_output_paths()
2502 spec->aamix_mode); in update_output_paths()
2510 struct hda_gen_spec *spec = codec->spec; in loopback_mixing_put()
2511 const struct auto_pin_cfg *cfg = &spec->autocfg; in loopback_mixing_put()
2512 unsigned int val = ucontrol->value.enumerated.item[0]; in loopback_mixing_put() local
2514 if (val == spec->aamix_mode) in loopback_mixing_put()
2516 spec->aamix_mode = val; in loopback_mixing_put()
2518 update_aamix_paths(codec, val, spec->out_paths[0], in loopback_mixing_put()
2519 spec->aamix_out_paths[0], in loopback_mixing_put()
2520 cfg->line_out_type); in loopback_mixing_put()
2521 update_aamix_paths(codec, val, spec->hp_paths[0], in loopback_mixing_put()
2522 spec->aamix_out_paths[1], in loopback_mixing_put()
2524 update_aamix_paths(codec, val, spec->speaker_paths[0], in loopback_mixing_put()
2525 spec->aamix_out_paths[2], in loopback_mixing_put()
2528 update_output_paths(codec, cfg->line_outs, spec->out_paths); in loopback_mixing_put()
2529 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in loopback_mixing_put()
2530 update_output_paths(codec, cfg->hp_outs, spec->hp_paths); in loopback_mixing_put()
2531 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in loopback_mixing_put()
2532 update_output_paths(codec, cfg->speaker_outs, in loopback_mixing_put()
2533 spec->speaker_paths); in loopback_mixing_put()
2548 struct hda_gen_spec *spec = codec->spec; in create_loopback_mixing_ctl()
2550 if (!spec->mixer_nid) in create_loopback_mixing_ctl()
2553 return -ENOMEM; in create_loopback_mixing_ctl()
2554 spec->have_aamix_ctl = 1; in create_loopback_mixing_ctl()
2564 /* for shared I/O, change the pin-control accordingly */
2567 struct hda_gen_spec *spec = codec->spec; in update_hp_mic()
2569 unsigned int val; in update_hp_mic() local
2570 hda_nid_t pin; in update_hp_mic() local
2572 pin = spec->hp_mic_pin; in update_hp_mic()
2573 as_mic = spec->cur_mux[adc_mux] == spec->hp_mic_mux_idx; in update_hp_mic()
2576 val = snd_hda_codec_get_pin_target(codec, pin); in update_hp_mic()
2578 if (val & PIN_IN) in update_hp_mic()
2581 if (val & PIN_OUT) in update_hp_mic()
2586 val = snd_hda_get_default_vref(codec, pin); in update_hp_mic()
2587 /* if the HP pin doesn't support VREF and the codec driver gives an in update_hp_mic()
2588 * alternative pin, set up the VREF on that pin instead in update_hp_mic()
2590 if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { in update_hp_mic()
2591 const hda_nid_t vref_pin = spec->shared_mic_vref_pin; in update_hp_mic()
2598 if (!spec->hp_mic_jack_modes) { in update_hp_mic()
2600 val |= PIN_IN; in update_hp_mic()
2602 val = PIN_HP; in update_hp_mic()
2603 set_pin_target(codec, pin, val, true); in update_hp_mic()
2611 struct hda_gen_spec *spec = codec->spec; in create_hp_mic()
2612 struct auto_pin_cfg *cfg = &spec->autocfg; in create_hp_mic()
2616 if (!spec->hp_mic) { in create_hp_mic()
2617 if (spec->suppress_hp_mic_detect) in create_hp_mic()
2620 * input pin is found, try to detect the shared hp/mic in create_hp_mic()
2622 if (cfg->num_inputs > 1) in create_hp_mic()
2624 else if (cfg->num_inputs == 1) { in create_hp_mic()
2625 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); in create_hp_mic()
2631 spec->hp_mic = 0; /* clear once */ in create_hp_mic()
2632 if (cfg->num_inputs >= AUTO_CFG_MAX_INS) in create_hp_mic()
2636 if (cfg->line_out_type == AUTO_PIN_HP_OUT && cfg->line_outs > 0) in create_hp_mic()
2637 nid = cfg->line_out_pins[0]; in create_hp_mic()
2638 else if (cfg->hp_outs > 0) in create_hp_mic()
2639 nid = cfg->hp_pins[0]; in create_hp_mic()
2646 cfg->inputs[cfg->num_inputs].pin = nid; in create_hp_mic()
2647 cfg->inputs[cfg->num_inputs].type = AUTO_PIN_MIC; in create_hp_mic()
2648 cfg->inputs[cfg->num_inputs].is_headphone_mic = 1; in create_hp_mic()
2649 cfg->num_inputs++; in create_hp_mic()
2650 spec->hp_mic = 1; in create_hp_mic()
2651 spec->hp_mic_pin = nid; in create_hp_mic()
2652 /* we can't handle auto-mic together with HP-mic */ in create_hp_mic()
2653 spec->suppress_auto_mic = 1; in create_hp_mic()
2662 static int create_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t pin);
2678 hda_nid_t nid = kcontrol->private_value; in out_jack_mode_get()
2680 ucontrol->value.enumerated.item[0] = 1; in out_jack_mode_get()
2682 ucontrol->value.enumerated.item[0] = 0; in out_jack_mode_get()
2690 hda_nid_t nid = kcontrol->private_value; in out_jack_mode_put()
2691 unsigned int val; in out_jack_mode_put() local
2693 val = ucontrol->value.enumerated.item[0] ? PIN_HP : PIN_OUT; in out_jack_mode_put()
2694 if (snd_hda_codec_get_pin_target(codec, nid) == val) in out_jack_mode_put()
2696 snd_hda_set_pin_ctl_cache(codec, nid, val); in out_jack_mode_put()
2709 struct hda_gen_spec *spec = codec->spec; in find_kctl_name()
2713 snd_array_for_each(&spec->kctls, i, kctl) { in find_kctl_name()
2714 if (!strcmp(kctl->name, name) && kctl->index == idx) in find_kctl_name()
2720 static void get_jack_mode_name(struct hda_codec *codec, hda_nid_t pin, in get_jack_mode_name() argument
2723 struct hda_gen_spec *spec = codec->spec; in get_jack_mode_name()
2726 snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len, &idx); in get_jack_mode_name()
2733 static int get_out_jack_num_items(struct hda_codec *codec, hda_nid_t pin) in get_out_jack_num_items() argument
2735 struct hda_gen_spec *spec = codec->spec; in get_out_jack_num_items()
2736 if (spec->add_jack_modes) { in get_out_jack_num_items()
2737 unsigned int pincap = snd_hda_query_pin_caps(codec, pin); in get_out_jack_num_items()
2747 struct hda_gen_spec *spec = codec->spec; in create_out_jack_modes()
2751 hda_nid_t pin = pins[i]; in create_out_jack_modes() local
2752 if (pin == spec->hp_mic_pin) in create_out_jack_modes()
2754 if (get_out_jack_num_items(codec, pin) > 1) { in create_out_jack_modes()
2757 get_jack_mode_name(codec, pin, name, sizeof(name)); in create_out_jack_modes()
2761 return -ENOMEM; in create_out_jack_modes()
2762 knew->private_value = pin; in create_out_jack_modes()
2781 static unsigned int get_vref_caps(struct hda_codec *codec, hda_nid_t pin) in get_vref_caps() argument
2785 pincap = snd_hda_query_pin_caps(codec, pin); in get_vref_caps()
2825 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_info()
2831 strcpy(uinfo->value.enumerated.name, in in_jack_mode_info()
2832 vref_texts[get_vref_idx(vref_caps, uinfo->value.enumerated.item)]); in in_jack_mode_info()
2840 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_get()
2845 ucontrol->value.enumerated.item[0] = cvt_from_vref_idx(vref_caps, idx); in in_jack_mode_get()
2853 hda_nid_t nid = kcontrol->private_value; in in_jack_mode_put()
2855 unsigned int val, idx; in in_jack_mode_put() local
2857 val = snd_hda_codec_get_pin_target(codec, nid); in in_jack_mode_put()
2858 idx = cvt_from_vref_idx(vref_caps, val & AC_PINCTL_VREFEN); in in_jack_mode_put()
2859 if (idx == ucontrol->value.enumerated.item[0]) in in_jack_mode_put()
2862 val &= ~AC_PINCTL_VREFEN; in in_jack_mode_put()
2863 val |= get_vref_idx(vref_caps, ucontrol->value.enumerated.item[0]); in in_jack_mode_put()
2864 snd_hda_set_pin_ctl_cache(codec, nid, val); in in_jack_mode_put()
2875 static int get_in_jack_num_items(struct hda_codec *codec, hda_nid_t pin) in get_in_jack_num_items() argument
2877 struct hda_gen_spec *spec = codec->spec; in get_in_jack_num_items()
2879 if (spec->add_jack_modes) in get_in_jack_num_items()
2880 nitems = hweight32(get_vref_caps(codec, pin)); in get_in_jack_num_items()
2884 static int create_in_jack_mode(struct hda_codec *codec, hda_nid_t pin) in create_in_jack_mode() argument
2886 struct hda_gen_spec *spec = codec->spec; in create_in_jack_mode()
2891 if (pin == spec->hp_mic_pin) in create_in_jack_mode()
2895 defcfg = snd_hda_codec_get_pincfg(codec, pin); in create_in_jack_mode()
2900 if (get_in_jack_num_items(codec, pin) <= 1) in create_in_jack_mode()
2903 get_jack_mode_name(codec, pin, name, sizeof(name)); in create_in_jack_mode()
2906 return -ENOMEM; in create_in_jack_mode()
2907 knew->private_value = pin; in create_in_jack_mode()
2918 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_info()
2924 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in hp_mic_jack_mode_info()
2925 uinfo->count = 1; in hp_mic_jack_mode_info()
2926 uinfo->value.enumerated.items = out_jacks + in_jacks; in hp_mic_jack_mode_info()
2927 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) in hp_mic_jack_mode_info()
2928 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; in hp_mic_jack_mode_info()
2929 idx = uinfo->value.enumerated.item; in hp_mic_jack_mode_info()
2936 idx -= out_jacks; in hp_mic_jack_mode_info()
2944 strcpy(uinfo->value.enumerated.name, text); in hp_mic_jack_mode_info()
2952 unsigned int val = snd_hda_codec_get_pin_target(codec, nid); in get_cur_hp_mic_jack_mode() local
2955 if (val & PIN_OUT) { in get_cur_hp_mic_jack_mode()
2956 if (out_jacks > 1 && val == PIN_HP) in get_cur_hp_mic_jack_mode()
2958 } else if (val & PIN_IN) { in get_cur_hp_mic_jack_mode()
2962 val &= AC_PINCTL_VREFEN; in get_cur_hp_mic_jack_mode()
2963 idx += cvt_from_vref_idx(vref_caps, val); in get_cur_hp_mic_jack_mode()
2973 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_get()
2974 ucontrol->value.enumerated.item[0] = in hp_mic_jack_mode_get()
2983 hda_nid_t nid = kcontrol->private_value; in hp_mic_jack_mode_put()
2986 unsigned int val, oldval, idx; in hp_mic_jack_mode_put() local
2989 idx = ucontrol->value.enumerated.item[0]; in hp_mic_jack_mode_put()
2995 val = idx ? PIN_HP : PIN_OUT; in hp_mic_jack_mode_put()
2997 val = PIN_HP; in hp_mic_jack_mode_put()
2999 idx -= out_jacks; in hp_mic_jack_mode_put()
3002 val = snd_hda_codec_get_pin_target(codec, nid); in hp_mic_jack_mode_put()
3003 val &= ~(AC_PINCTL_VREFEN | PIN_HP); in hp_mic_jack_mode_put()
3004 val |= get_vref_idx(vref_caps, idx) | PIN_IN; in hp_mic_jack_mode_put()
3006 val = snd_hda_get_default_vref(codec, nid) | PIN_IN; in hp_mic_jack_mode_put()
3008 snd_hda_set_pin_ctl_cache(codec, nid, val); in hp_mic_jack_mode_put()
3021 static int create_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t pin) in create_hp_mic_jack_mode() argument
3023 struct hda_gen_spec *spec = codec->spec; in create_hp_mic_jack_mode()
3029 return -ENOMEM; in create_hp_mic_jack_mode()
3030 knew->private_value = pin; in create_hp_mic_jack_mode()
3031 spec->hp_mic_jack_modes = 1; in create_hp_mic_jack_mode()
3039 /* add the powersave loopback-list entry */
3044 list = snd_array_new(&spec->loopback_list); in add_loopback_list()
3046 return -ENOMEM; in add_loopback_list()
3047 list->nid = mix; in add_loopback_list()
3048 list->dir = HDA_INPUT; in add_loopback_list()
3049 list->idx = idx; in add_loopback_list()
3050 spec->loopback.amplist = spec->loopback_list.list; in add_loopback_list()
3058 hda_nid_t pin, unsigned int *mix_val, in look_for_mix_leaf_ctls() argument
3065 idx = snd_hda_get_conn_index(codec, mix_nid, pin, true); in look_for_mix_leaf_ctls()
3092 /* create input playback/capture controls for the given pin */
3094 hda_nid_t pin, const char *ctlname, int ctlidx, in new_analog_input() argument
3097 struct hda_gen_spec *spec = codec->spec; in new_analog_input()
3102 if (!look_for_mix_leaf_ctls(codec, mix_nid, pin, &mix_val, &mute_val)) in new_analog_input()
3105 path = snd_hda_add_new_path(codec, pin, mix_nid, 0); in new_analog_input()
3107 return -EINVAL; in new_analog_input()
3109 spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path); in new_analog_input()
3111 idx = path->idx[path->depth - 1]; in new_analog_input()
3116 path->ctls[NID_PATH_VOL_CTL] = mix_val; in new_analog_input()
3123 path->ctls[NID_PATH_MUTE_CTL] = mute_val; in new_analog_input()
3126 path->active = true; in new_analog_input()
3127 path->stream_enabled = true; /* no DAC/ADC involved */ in new_analog_input()
3132 if (spec->mixer_nid != spec->mixer_merge_nid && in new_analog_input()
3133 !spec->loopback_merge_path) { in new_analog_input()
3134 path = snd_hda_add_new_path(codec, spec->mixer_nid, in new_analog_input()
3135 spec->mixer_merge_nid, 0); in new_analog_input()
3137 print_nid_path(codec, "loopback-merge", path); in new_analog_input()
3138 path->active = true; in new_analog_input()
3139 path->pin_fixed = true; /* static route */ in new_analog_input()
3140 path->stream_enabled = true; /* no DAC/ADC involved */ in new_analog_input()
3141 spec->loopback_merge_path = in new_analog_input()
3158 struct hda_gen_spec *spec = codec->spec; in fill_adc_nids()
3160 hda_nid_t *adc_nids = spec->adc_nids; in fill_adc_nids()
3161 int max_nums = ARRAY_SIZE(spec->adc_nids); in fill_adc_nids()
3174 spec->num_adc_nids = nums; in fill_adc_nids()
3177 spec->num_all_adcs = nums; in fill_adc_nids()
3178 memcpy(spec->all_adcs, spec->adc_nids, nums * sizeof(hda_nid_t)); in fill_adc_nids()
3184 * if needed, check whether dynamic ADC-switching is available
3188 struct hda_gen_spec *spec = codec->spec; in check_dyn_adc_switch()
3189 struct hda_input_mux *imux = &spec->input_mux; in check_dyn_adc_switch()
3195 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3196 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3197 if (!spec->input_paths[i][n]) in check_dyn_adc_switch()
3200 if (i >= imux->num_items) { in check_dyn_adc_switch()
3207 /* check whether ADC-switch is possible */ in check_dyn_adc_switch()
3208 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3209 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3210 if (spec->input_paths[i][n]) { in check_dyn_adc_switch()
3211 spec->dyn_adc_idx[i] = n; in check_dyn_adc_switch()
3218 spec->dyn_adc_switch = 1; in check_dyn_adc_switch()
3219 } else if (nums != spec->num_adc_nids) { in check_dyn_adc_switch()
3222 for (n = 0; n < spec->num_adc_nids; n++) { in check_dyn_adc_switch()
3226 spec->adc_nids[nums] = spec->adc_nids[n]; in check_dyn_adc_switch()
3227 for (i = 0; i < imux->num_items; i++) { in check_dyn_adc_switch()
3229 spec->input_paths[i][nums]); in check_dyn_adc_switch()
3230 spec->input_paths[i][nums] = in check_dyn_adc_switch()
3231 spec->input_paths[i][n]; in check_dyn_adc_switch()
3232 spec->input_paths[i][n] = 0; in check_dyn_adc_switch()
3237 spec->num_adc_nids = nums; in check_dyn_adc_switch()
3240 if (imux->num_items == 1 || in check_dyn_adc_switch()
3241 (imux->num_items == 2 && spec->hp_mic)) { in check_dyn_adc_switch()
3243 spec->num_adc_nids = 1; /* reduce to a single ADC */ in check_dyn_adc_switch()
3247 if (!spec->dyn_adc_switch && spec->multi_cap_vol) in check_dyn_adc_switch()
3248 spec->num_adc_nids = 1; in check_dyn_adc_switch()
3253 /* parse capture source paths from the given pin and create imux items */
3254 static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin, in parse_capture_source() argument
3258 struct hda_gen_spec *spec = codec->spec; in parse_capture_source()
3259 struct hda_input_mux *imux = &spec->input_mux; in parse_capture_source()
3260 int imux_idx = imux->num_items; in parse_capture_source()
3266 hda_nid_t adc = spec->adc_nids[c]; in parse_capture_source()
3268 if (!is_reachable_path(codec, pin, adc)) in parse_capture_source()
3270 path = snd_hda_add_new_path(codec, pin, adc, anchor); in parse_capture_source()
3274 spec->input_paths[imux_idx][c] = in parse_capture_source()
3278 if (spec->hp_mic_pin == pin) in parse_capture_source()
3279 spec->hp_mic_mux_idx = imux->num_items; in parse_capture_source()
3280 spec->imux_pins[imux->num_items] = pin; in parse_capture_source()
3283 if (spec->dyn_adc_switch) in parse_capture_source()
3284 spec->dyn_adc_idx[imux_idx] = c; in parse_capture_source()
3298 struct hda_gen_spec *spec = codec->spec; in fill_input_pin_labels()
3299 const struct auto_pin_cfg *cfg = &spec->autocfg; in fill_input_pin_labels()
3302 for (i = 0; i < cfg->num_inputs; i++) { in fill_input_pin_labels()
3303 hda_nid_t pin = cfg->inputs[i].pin; in fill_input_pin_labels() local
3307 if (!is_input_pin(codec, pin)) in fill_input_pin_labels()
3312 for (j = i - 1; j >= 0; j--) { in fill_input_pin_labels()
3313 if (spec->input_labels[j] && in fill_input_pin_labels()
3314 !strcmp(spec->input_labels[j], label)) { in fill_input_pin_labels()
3315 idx = spec->input_label_idxs[j] + 1; in fill_input_pin_labels()
3320 spec->input_labels[i] = label; in fill_input_pin_labels()
3321 spec->input_label_idxs[i] = idx; in fill_input_pin_labels()
3327 #define CFG_IDX_MIX 99 /* a dummy cfg->input idx for stereo mix */
3331 struct hda_gen_spec *spec = codec->spec; in create_input_ctls()
3332 const struct auto_pin_cfg *cfg = &spec->autocfg; in create_input_ctls()
3333 hda_nid_t mixer = spec->mixer_nid; in create_input_ctls()
3336 unsigned int val; in create_input_ctls() local
3346 for (i = 0; i < cfg->num_inputs; i++) { in create_input_ctls()
3347 hda_nid_t pin; in create_input_ctls() local
3349 pin = cfg->inputs[i].pin; in create_input_ctls()
3350 if (!is_input_pin(codec, pin)) in create_input_ctls()
3353 val = PIN_IN; in create_input_ctls()
3354 if (cfg->inputs[i].type == AUTO_PIN_MIC) in create_input_ctls()
3355 val |= snd_hda_get_default_vref(codec, pin); in create_input_ctls()
3356 if (pin != spec->hp_mic_pin && in create_input_ctls()
3357 !snd_hda_codec_get_pin_target(codec, pin)) in create_input_ctls()
3358 set_pin_target(codec, pin, val, false); in create_input_ctls()
3361 if (is_reachable_path(codec, pin, mixer)) { in create_input_ctls()
3362 err = new_analog_input(codec, i, pin, in create_input_ctls()
3363 spec->input_labels[i], in create_input_ctls()
3364 spec->input_label_idxs[i], in create_input_ctls()
3371 err = parse_capture_source(codec, pin, i, num_adcs, in create_input_ctls()
3372 spec->input_labels[i], -mixer); in create_input_ctls()
3376 if (spec->add_jack_modes) { in create_input_ctls()
3377 err = create_in_jack_mode(codec, pin); in create_input_ctls()
3384 if (mixer && spec->add_stereo_mix_input == HDA_HINT_STEREO_MIX_ENABLE) { in create_input_ctls()
3390 spec->suppress_auto_mic = 1; in create_input_ctls()
3404 struct hda_gen_spec *spec = codec->spec; in get_input_path()
3409 if (spec->dyn_adc_switch) in get_input_path()
3410 adc_idx = spec->dyn_adc_idx[imux_idx]; in get_input_path()
3415 return snd_hda_get_path_from_idx(codec, spec->input_paths[imux_idx][adc_idx]); in get_input_path()
3425 struct hda_gen_spec *spec = codec->spec; in mux_enum_info()
3426 return snd_hda_input_mux_info(&spec->input_mux, uinfo); in mux_enum_info()
3433 struct hda_gen_spec *spec = codec->spec; in mux_enum_get()
3435 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in mux_enum_get()
3437 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; in mux_enum_get()
3445 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in mux_enum_put()
3447 ucontrol->value.enumerated.item[0]); in mux_enum_put()
3471 struct hda_gen_spec *spec = codec->spec; in cap_put_caller()
3476 imux = &spec->input_mux; in cap_put_caller()
3477 adc_idx = kcontrol->id.index; in cap_put_caller()
3478 mutex_lock(&codec->control_mutex); in cap_put_caller()
3479 for (i = 0; i < imux->num_items; i++) { in cap_put_caller()
3481 if (!path || !path->ctls[type]) in cap_put_caller()
3483 kcontrol->private_value = path->ctls[type]; in cap_put_caller()
3492 mutex_unlock(&codec->control_mutex); in cap_put_caller()
3493 if (err >= 0 && spec->cap_sync_hook) in cap_put_caller()
3494 spec->cap_sync_hook(codec, kcontrol, ucontrol); in cap_put_caller()
3549 path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0; in parse_capvol_in_path()
3551 if (depth >= path->depth) in parse_capvol_in_path()
3552 return -EINVAL; in parse_capvol_in_path()
3553 i = path->depth - depth - 1; in parse_capvol_in_path()
3554 nid = path->path[i]; in parse_capvol_in_path()
3555 if (!path->ctls[NID_PATH_VOL_CTL]) { in parse_capvol_in_path()
3557 path->ctls[NID_PATH_VOL_CTL] = in parse_capvol_in_path()
3560 int idx = path->idx[i]; in parse_capvol_in_path()
3561 if (!depth && codec->single_adc_amp) in parse_capvol_in_path()
3563 path->ctls[NID_PATH_VOL_CTL] = in parse_capvol_in_path()
3567 if (!path->ctls[NID_PATH_MUTE_CTL]) { in parse_capvol_in_path()
3569 path->ctls[NID_PATH_MUTE_CTL] = in parse_capvol_in_path()
3572 int idx = path->idx[i]; in parse_capvol_in_path()
3573 if (!depth && codec->single_adc_amp) in parse_capvol_in_path()
3575 path->ctls[NID_PATH_MUTE_CTL] = in parse_capvol_in_path()
3585 struct hda_gen_spec *spec = codec->spec; in is_inv_dmic_pin()
3586 struct auto_pin_cfg *cfg = &spec->autocfg; in is_inv_dmic_pin()
3587 unsigned int val; in is_inv_dmic_pin() local
3590 if (!spec->inv_dmic_split) in is_inv_dmic_pin()
3592 for (i = 0; i < cfg->num_inputs; i++) { in is_inv_dmic_pin()
3593 if (cfg->inputs[i].pin != nid) in is_inv_dmic_pin()
3595 if (cfg->inputs[i].type != AUTO_PIN_MIC) in is_inv_dmic_pin()
3597 val = snd_hda_codec_get_pincfg(codec, nid); in is_inv_dmic_pin()
3598 return snd_hda_get_input_pin_attr(val) == INPUT_PIN_ATTR_INT; in is_inv_dmic_pin()
3608 struct hda_gen_spec *spec = codec->spec; in cap_single_sw_put()
3615 if (spec->cap_sync_hook) in cap_single_sw_put()
3616 spec->cap_sync_hook(codec, kcontrol, ucontrol); in cap_single_sw_put()
3625 struct hda_gen_spec *spec = codec->spec; in add_single_cap_ctl()
3644 return -ENOMEM; in add_single_cap_ctl()
3646 knew->put = cap_single_sw_put; in add_single_cap_ctl()
3647 if (spec->mic_mute_led) in add_single_cap_ctl()
3648 knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED; in add_single_cap_ctl()
3663 return -ENOMEM; in add_single_cap_ctl()
3665 knew->put = cap_single_sw_put; in add_single_cap_ctl()
3666 if (spec->mic_mute_led) in add_single_cap_ctl()
3667 knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED; in add_single_cap_ctl()
3691 struct hda_gen_spec *spec = codec->spec; in create_bind_cap_vol_ctl()
3697 return -ENOMEM; in create_bind_cap_vol_ctl()
3698 knew->index = idx; in create_bind_cap_vol_ctl()
3699 knew->private_value = vol_ctl; in create_bind_cap_vol_ctl()
3700 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in create_bind_cap_vol_ctl()
3705 return -ENOMEM; in create_bind_cap_vol_ctl()
3706 knew->index = idx; in create_bind_cap_vol_ctl()
3707 knew->private_value = sw_ctl; in create_bind_cap_vol_ctl()
3708 knew->subdevice = HDA_SUBDEV_AMP_FLAG; in create_bind_cap_vol_ctl()
3709 if (spec->mic_mute_led) in create_bind_cap_vol_ctl()
3710 knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED; in create_bind_cap_vol_ctl()
3725 ctl = path->ctls[type]; in get_first_cap_ctl()
3728 for (i = 0; i < idx - 1; i++) { in get_first_cap_ctl()
3730 if (path && path->ctls[type] == ctl) in get_first_cap_ctl()
3739 struct hda_gen_spec *spec = codec->spec; in create_multi_cap_vol_ctl()
3740 struct hda_input_mux *imux = &spec->input_mux; in create_multi_cap_vol_ctl()
3743 for (i = 0; i < imux->num_items; i++) { in create_multi_cap_vol_ctl()
3747 idx = imux->items[i].index; in create_multi_cap_vol_ctl()
3748 if (idx >= spec->autocfg.num_inputs) in create_multi_cap_vol_ctl()
3750 inv_dmic = is_inv_dmic_pin(codec, spec->imux_pins[i]); in create_multi_cap_vol_ctl()
3754 spec->input_labels[idx], in create_multi_cap_vol_ctl()
3755 spec->input_label_idxs[idx], in create_multi_cap_vol_ctl()
3768 struct hda_gen_spec *spec = codec->spec; in create_capture_mixers()
3769 struct hda_input_mux *imux = &spec->input_mux; in create_capture_mixers()
3772 if (spec->dyn_adc_switch) in create_capture_mixers()
3775 nums = spec->num_adc_nids; in create_capture_mixers()
3777 if (!spec->auto_mic && imux->num_items > 1) { in create_capture_mixers()
3783 return -ENOMEM; in create_capture_mixers()
3784 knew->count = nums; in create_capture_mixers()
3789 bool multi_cap_vol = spec->multi_cap_vol; in create_capture_mixers()
3794 for (i = 0; i < imux->num_items; i++) { in create_capture_mixers()
3801 vol = path->ctls[NID_PATH_VOL_CTL]; in create_capture_mixers()
3802 else if (vol != path->ctls[NID_PATH_VOL_CTL]) { in create_capture_mixers()
3805 path->ctls[NID_PATH_VOL_CTL], HDA_INPUT)) in create_capture_mixers()
3809 sw = path->ctls[NID_PATH_MUTE_CTL]; in create_capture_mixers()
3810 else if (sw != path->ctls[NID_PATH_MUTE_CTL]) { in create_capture_mixers()
3813 path->ctls[NID_PATH_MUTE_CTL], HDA_INPUT)) in create_capture_mixers()
3816 if (is_inv_dmic_pin(codec, spec->imux_pins[i])) in create_capture_mixers()
3856 /* look for a boost amp in a widget close to the pin */
3860 unsigned int val = 0; in look_for_boost_amp() local
3865 if (depth >= path->depth - 1) in look_for_boost_amp()
3867 nid = path->path[depth]; in look_for_boost_amp()
3869 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); in look_for_boost_amp()
3872 path->idx[depth])) { in look_for_boost_amp()
3873 val = HDA_COMPOSE_AMP_VAL(nid, 3, path->idx[depth], in look_for_boost_amp()
3879 return val; in look_for_boost_amp()
3884 struct hda_gen_spec *spec = codec->spec; in parse_mic_boost()
3885 struct auto_pin_cfg *cfg = &spec->autocfg; in parse_mic_boost()
3886 struct hda_input_mux *imux = &spec->input_mux; in parse_mic_boost()
3889 if (!spec->num_adc_nids) in parse_mic_boost()
3892 for (i = 0; i < imux->num_items; i++) { in parse_mic_boost()
3894 unsigned int val; in parse_mic_boost() local
3898 idx = imux->items[i].index; in parse_mic_boost()
3899 if (idx >= imux->num_items) in parse_mic_boost()
3902 /* check only line-in and mic pins */ in parse_mic_boost()
3903 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN) in parse_mic_boost()
3910 val = look_for_boost_amp(codec, path); in parse_mic_boost()
3911 if (!val) in parse_mic_boost()
3916 "%s Boost Volume", spec->input_labels[idx]); in parse_mic_boost()
3918 spec->input_label_idxs[idx], val)) in parse_mic_boost()
3919 return -ENOMEM; in parse_mic_boost()
3921 path->ctls[NID_PATH_BOOST_CTL] = val; in parse_mic_boost()
3936 struct hda_gen_spec *spec = codec->spec; in create_mute_led_cdev()
3941 cdev = devm_kzalloc(&codec->core.dev, sizeof(*cdev), GFP_KERNEL); in create_mute_led_cdev()
3943 return -ENOMEM; in create_mute_led_cdev()
3945 cdev->name = micmute ? "hda::micmute" : "hda::mute"; in create_mute_led_cdev()
3946 cdev->max_brightness = 1; in create_mute_led_cdev()
3947 cdev->default_trigger = micmute ? "audio-micmute" : "audio-mute"; in create_mute_led_cdev()
3948 cdev->brightness_set_blocking = callback; in create_mute_led_cdev()
3949 cdev->flags = LED_CORE_SUSPENDRESUME; in create_mute_led_cdev()
3951 err = led_classdev_register(&codec->core.dev, cdev); in create_mute_led_cdev()
3954 spec->led_cdevs[idx] = cdev; in create_mute_led_cdev()
3959 * snd_hda_gen_add_mute_led_cdev - Create a LED classdev and enable as vmaster mute LED
3967 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_add_mute_led_cdev()
3978 if (spec->vmaster_mute.hook) in snd_hda_gen_add_mute_led_cdev()
3981 spec->vmaster_mute_led = 1; in snd_hda_gen_add_mute_led_cdev()
3987 * snd_hda_gen_add_micmute_led_cdev - Create a LED classdev and enable as mic-mute LED
3996 * LED-trigger is set up.
4004 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_add_micmute_led_cdev()
4010 codec_warn(codec, "failed to create a mic-mute LED cdev\n"); in snd_hda_gen_add_micmute_led_cdev()
4015 spec->mic_mute_led = 1; in snd_hda_gen_add_micmute_led_cdev()
4022 * parse digital I/Os and set up NIDs in BIOS auto-parse mode
4026 struct hda_gen_spec *spec = codec->spec; in parse_digital()
4029 hda_nid_t dig_nid, pin; in parse_digital() local
4033 for (i = 0; i < spec->autocfg.dig_outs; i++) { in parse_digital()
4034 pin = spec->autocfg.dig_out_pins[i]; in parse_digital()
4035 dig_nid = look_for_dac(codec, pin, true); in parse_digital()
4038 path = snd_hda_add_new_path(codec, dig_nid, pin, 0); in parse_digital()
4042 path->active = true; in parse_digital()
4043 path->pin_fixed = true; /* no jack detection */ in parse_digital()
4044 spec->digout_paths[i] = snd_hda_get_path_idx(codec, path); in parse_digital()
4045 set_pin_target(codec, pin, PIN_OUT, false); in parse_digital()
4047 spec->multiout.dig_out_nid = dig_nid; in parse_digital()
4048 spec->dig_out_type = spec->autocfg.dig_out_type[0]; in parse_digital()
4050 spec->multiout.follower_dig_outs = spec->follower_dig_outs; in parse_digital()
4051 if (nums >= ARRAY_SIZE(spec->follower_dig_outs) - 1) in parse_digital()
4053 spec->follower_dig_outs[nums - 1] = dig_nid; in parse_digital()
4058 if (spec->autocfg.dig_in_pin) { in parse_digital()
4059 pin = spec->autocfg.dig_in_pin; in parse_digital()
4066 path = snd_hda_add_new_path(codec, pin, dig_nid, 0); in parse_digital()
4069 path->active = true; in parse_digital()
4070 path->pin_fixed = true; /* no jack */ in parse_digital()
4071 spec->dig_in_nid = dig_nid; in parse_digital()
4072 spec->digin_path = snd_hda_get_path_idx(codec, path); in parse_digital()
4073 set_pin_target(codec, pin, PIN_IN, false); in parse_digital()
4091 struct hda_gen_spec *spec = codec->spec; in mux_select()
4095 imux = &spec->input_mux; in mux_select()
4096 if (!imux->num_items) in mux_select()
4099 if (idx >= imux->num_items) in mux_select()
4100 idx = imux->num_items - 1; in mux_select()
4101 if (spec->cur_mux[adc_idx] == idx) in mux_select()
4104 old_path = get_input_path(codec, adc_idx, spec->cur_mux[adc_idx]); in mux_select()
4107 if (old_path->active) in mux_select()
4110 spec->cur_mux[adc_idx] = idx; in mux_select()
4112 if (spec->hp_mic) in mux_select()
4115 if (spec->dyn_adc_switch) in mux_select()
4121 if (path->active) in mux_select()
4124 if (spec->cap_sync_hook) in mux_select()
4125 spec->cap_sync_hook(codec, NULL, NULL); in mux_select()
4131 * as terminals (either start- or endpoint)
4138 struct hda_gen_spec *spec = codec->spec; in set_path_power()
4143 snd_array_for_each(&spec->paths, n, path) { in set_path_power()
4144 if (!path->depth) in set_path_power()
4146 if (path->path[0] == nid || in set_path_power()
4147 path->path[path->depth - 1] == nid) { in set_path_power()
4148 bool pin_old = path->pin_enabled; in set_path_power()
4149 bool stream_old = path->stream_enabled; in set_path_power()
4152 path->pin_enabled = pin_state; in set_path_power()
4154 path->stream_enabled = stream_state; in set_path_power()
4155 if ((!path->pin_fixed && path->pin_enabled != pin_old) in set_path_power()
4156 || path->stream_enabled != stream_old) { in set_path_power()
4167 static bool detect_pin_state(struct hda_codec *codec, hda_nid_t pin) in detect_pin_state() argument
4169 if (!is_jack_detectable(codec, pin)) in detect_pin_state()
4171 return snd_hda_jack_detect_state(codec, pin) != HDA_JACK_NOT_PRESENT; in detect_pin_state()
4174 /* power up/down the paths of the given pin according to the jack state;
4180 static hda_nid_t set_pin_power_jack(struct hda_codec *codec, hda_nid_t pin, in set_pin_power_jack() argument
4185 if (!codec->power_save_node) in set_pin_power_jack()
4188 on = detect_pin_state(codec, pin); in set_pin_power_jack()
4192 return set_path_power(codec, pin, on, -1); in set_pin_power_jack()
4199 if (jack && jack->nid) in pin_power_callback()
4201 set_pin_power_jack(codec, jack->nid, on)); in pin_power_callback()
4204 /* callback only doing power up -- called at first */
4211 /* callback only doing power down -- called at last */
4230 set_path_power(codec, pins[i], true, -1); in add_pin_power_ctls()
4234 /* enabled power callback to each available I/O pin with jack detections;
4239 struct hda_gen_spec *spec = codec->spec; in add_all_pin_power_ctls()
4240 struct auto_pin_cfg *cfg = &spec->autocfg; in add_all_pin_power_ctls()
4243 if (!codec->power_save_node) in add_all_pin_power_ctls()
4245 add_pin_power_ctls(codec, cfg->line_outs, cfg->line_out_pins, on); in add_all_pin_power_ctls()
4246 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in add_all_pin_power_ctls()
4247 add_pin_power_ctls(codec, cfg->hp_outs, cfg->hp_pins, on); in add_all_pin_power_ctls()
4248 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in add_all_pin_power_ctls()
4249 add_pin_power_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, on); in add_all_pin_power_ctls()
4250 for (i = 0; i < cfg->num_inputs; i++) in add_all_pin_power_ctls()
4251 add_pin_power_ctls(codec, 1, &cfg->inputs[i].pin, on); in add_all_pin_power_ctls()
4262 set_pin_power_jack(codec, pins[i], -1); in sync_pin_power_ctls()
4268 struct hda_gen_spec *spec = codec->spec; in sync_all_pin_power_ctls()
4269 struct auto_pin_cfg *cfg = &spec->autocfg; in sync_all_pin_power_ctls()
4272 if (!codec->power_save_node) in sync_all_pin_power_ctls()
4274 sync_pin_power_ctls(codec, cfg->line_outs, cfg->line_out_pins); in sync_all_pin_power_ctls()
4275 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in sync_all_pin_power_ctls()
4276 sync_pin_power_ctls(codec, cfg->hp_outs, cfg->hp_pins); in sync_all_pin_power_ctls()
4277 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in sync_all_pin_power_ctls()
4278 sync_pin_power_ctls(codec, cfg->speaker_outs, cfg->speaker_pins); in sync_all_pin_power_ctls()
4279 for (i = 0; i < cfg->num_inputs; i++) in sync_all_pin_power_ctls()
4280 sync_pin_power_ctls(codec, 1, &cfg->inputs[i].pin); in sync_all_pin_power_ctls()
4287 struct hda_gen_spec *spec = codec->spec; in add_fake_paths()
4296 path = snd_array_new(&spec->paths); in add_fake_paths()
4298 return -ENOMEM; in add_fake_paths()
4300 path->depth = 2; in add_fake_paths()
4301 path->path[0] = nid; in add_fake_paths()
4302 path->path[1] = pins[i]; in add_fake_paths()
4303 path->active = true; in add_fake_paths()
4311 struct hda_gen_spec *spec = codec->spec; in add_fake_beep_paths()
4312 struct auto_pin_cfg *cfg = &spec->autocfg; in add_fake_beep_paths()
4313 hda_nid_t nid = spec->beep_nid; in add_fake_beep_paths()
4316 if (!codec->power_save_node || !nid) in add_fake_beep_paths()
4318 err = add_fake_paths(codec, nid, cfg->line_outs, cfg->line_out_pins); in add_fake_beep_paths()
4321 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in add_fake_beep_paths()
4322 err = add_fake_paths(codec, nid, cfg->hp_outs, cfg->hp_pins); in add_fake_beep_paths()
4326 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in add_fake_beep_paths()
4327 err = add_fake_paths(codec, nid, cfg->speaker_outs, in add_fake_beep_paths()
4328 cfg->speaker_pins); in add_fake_beep_paths()
4338 set_path_power(beep->codec, beep->nid, -1, on); in beep_power_hook()
4342 * snd_hda_gen_fix_pin_power - Fix the power of the given pin widget to D0
4344 * @pin: NID of pin to fix
4346 int snd_hda_gen_fix_pin_power(struct hda_codec *codec, hda_nid_t pin) in snd_hda_gen_fix_pin_power() argument
4348 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_fix_pin_power()
4351 path = snd_array_new(&spec->paths); in snd_hda_gen_fix_pin_power()
4353 return -ENOMEM; in snd_hda_gen_fix_pin_power()
4355 path->depth = 1; in snd_hda_gen_fix_pin_power()
4356 path->path[0] = pin; in snd_hda_gen_fix_pin_power()
4357 path->active = true; in snd_hda_gen_fix_pin_power()
4358 path->pin_fixed = true; in snd_hda_gen_fix_pin_power()
4359 path->stream_enabled = true; in snd_hda_gen_fix_pin_power()
4365 * Jack detections for HP auto-mute and mic-switch
4368 /* check each pin in the given array; returns true if any of them is plugged */
4387 /* standard HP/line-out auto-mute helper */
4391 struct hda_gen_spec *spec = codec->spec; in do_automute()
4396 unsigned int val, oldval; in do_automute() local
4404 if (spec->auto_mute_via_amp) { in do_automute()
4411 mute_nid = get_amp_nid_(path->ctls[NID_PATH_MUTE_CTL]); in do_automute()
4415 spec->mute_bits |= (1ULL << mute_nid); in do_automute()
4417 spec->mute_bits &= ~(1ULL << mute_nid); in do_automute()
4423 if (spec->keep_vref_in_automute) in do_automute()
4424 val = oldval & ~PIN_HP; in do_automute()
4426 val = 0; in do_automute()
4428 val |= oldval; in do_automute()
4434 update_pin_ctl(codec, nid, val); in do_automute()
4438 if (codec->power_save_node) { in do_automute()
4442 set_path_power(codec, nid, on, -1); in do_automute()
4448 * snd_hda_gen_update_outputs - Toggle outputs muting
4455 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_update_outputs()
4463 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) in snd_hda_gen_update_outputs()
4464 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4466 paths = spec->hp_paths; in snd_hda_gen_update_outputs()
4467 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), in snd_hda_gen_update_outputs()
4468 spec->autocfg.hp_pins, paths, spec->master_mute); in snd_hda_gen_update_outputs()
4470 if (!spec->automute_speaker) in snd_hda_gen_update_outputs()
4473 on = spec->hp_jack_present | spec->line_jack_present; in snd_hda_gen_update_outputs()
4474 on |= spec->master_mute; in snd_hda_gen_update_outputs()
4475 spec->speaker_muted = on; in snd_hda_gen_update_outputs()
4476 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_update_outputs()
4477 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4479 paths = spec->speaker_paths; in snd_hda_gen_update_outputs()
4480 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), in snd_hda_gen_update_outputs()
4481 spec->autocfg.speaker_pins, paths, on); in snd_hda_gen_update_outputs()
4483 /* toggle line-out mutes if needed, too */ in snd_hda_gen_update_outputs()
4485 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || in snd_hda_gen_update_outputs()
4486 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) in snd_hda_gen_update_outputs()
4488 if (!spec->automute_lo) in snd_hda_gen_update_outputs()
4491 on = spec->hp_jack_present; in snd_hda_gen_update_outputs()
4492 on |= spec->master_mute; in snd_hda_gen_update_outputs()
4493 spec->line_out_muted = on; in snd_hda_gen_update_outputs()
4494 paths = spec->out_paths; in snd_hda_gen_update_outputs()
4495 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), in snd_hda_gen_update_outputs()
4496 spec->autocfg.line_out_pins, paths, on); in snd_hda_gen_update_outputs()
4502 struct hda_gen_spec *spec = codec->spec; in call_update_outputs()
4503 if (spec->automute_hook) in call_update_outputs()
4504 spec->automute_hook(codec); in call_update_outputs()
4508 /* sync the whole vmaster followers to reflect the new auto-mute status */ in call_update_outputs()
4509 if (spec->auto_mute_via_amp && !codec->bus->shutdown) in call_update_outputs()
4510 snd_ctl_sync_vmaster(spec->vmaster_mute.sw_kctl, false); in call_update_outputs()
4514 * snd_hda_gen_hp_automute - standard HP-automute helper
4521 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_hp_automute()
4522 hda_nid_t *pins = spec->autocfg.hp_pins; in snd_hda_gen_hp_automute()
4523 int num_pins = ARRAY_SIZE(spec->autocfg.hp_pins); in snd_hda_gen_hp_automute()
4525 /* No detection for the first HP jack during indep-HP mode */ in snd_hda_gen_hp_automute()
4526 if (spec->indep_hp_enabled) { in snd_hda_gen_hp_automute()
4528 num_pins--; in snd_hda_gen_hp_automute()
4531 spec->hp_jack_present = detect_jacks(codec, num_pins, pins); in snd_hda_gen_hp_automute()
4532 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) in snd_hda_gen_hp_automute()
4539 * snd_hda_gen_line_automute - standard line-out-automute helper
4546 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_line_automute()
4548 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_line_automute()
4551 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) in snd_hda_gen_line_automute()
4554 spec->line_jack_present = in snd_hda_gen_line_automute()
4555 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), in snd_hda_gen_line_automute()
4556 spec->autocfg.line_out_pins); in snd_hda_gen_line_automute()
4557 if (!spec->automute_speaker || !spec->detect_lo) in snd_hda_gen_line_automute()
4564 * snd_hda_gen_mic_autoswitch - standard mic auto-switch helper
4571 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_mic_autoswitch()
4574 if (!spec->auto_mic) in snd_hda_gen_mic_autoswitch()
4577 for (i = spec->am_num_entries - 1; i > 0; i--) { in snd_hda_gen_mic_autoswitch()
4578 hda_nid_t pin = spec->am_entry[i].pin; in snd_hda_gen_mic_autoswitch() local
4580 if (snd_hda_codec_get_pin_target(codec, pin) & AC_PINCTL_OUT_EN) in snd_hda_gen_mic_autoswitch()
4582 if (snd_hda_jack_detect_state(codec, pin) == HDA_JACK_PRESENT) { in snd_hda_gen_mic_autoswitch()
4583 mux_select(codec, 0, spec->am_entry[i].idx); in snd_hda_gen_mic_autoswitch()
4587 mux_select(codec, 0, spec->am_entry[0].idx); in snd_hda_gen_mic_autoswitch()
4595 struct hda_gen_spec *spec = codec->spec; in call_hp_automute()
4596 if (spec->hp_automute_hook) in call_hp_automute()
4597 spec->hp_automute_hook(codec, jack); in call_hp_automute()
4605 struct hda_gen_spec *spec = codec->spec; in call_line_automute()
4606 if (spec->line_automute_hook) in call_line_automute()
4607 spec->line_automute_hook(codec, jack); in call_line_automute()
4615 struct hda_gen_spec *spec = codec->spec; in call_mic_autoswitch()
4616 if (spec->mic_autoswitch_hook) in call_mic_autoswitch()
4617 spec->mic_autoswitch_hook(codec, jack); in call_mic_autoswitch()
4631 * Auto-Mute mode mixer enum support
4637 struct hda_gen_spec *spec = codec->spec; in automute_mode_info()
4642 if (spec->automute_speaker_possible && spec->automute_lo_possible) in automute_mode_info()
4651 struct hda_gen_spec *spec = codec->spec; in automute_mode_get()
4652 unsigned int val = 0; in automute_mode_get() local
4653 if (spec->automute_speaker) in automute_mode_get()
4654 val++; in automute_mode_get()
4655 if (spec->automute_lo) in automute_mode_get()
4656 val++; in automute_mode_get()
4658 ucontrol->value.enumerated.item[0] = val; in automute_mode_get()
4666 struct hda_gen_spec *spec = codec->spec; in automute_mode_put()
4668 switch (ucontrol->value.enumerated.item[0]) { in automute_mode_put()
4670 if (!spec->automute_speaker && !spec->automute_lo) in automute_mode_put()
4672 spec->automute_speaker = 0; in automute_mode_put()
4673 spec->automute_lo = 0; in automute_mode_put()
4676 if (spec->automute_speaker_possible) { in automute_mode_put()
4677 if (!spec->automute_lo && spec->automute_speaker) in automute_mode_put()
4679 spec->automute_speaker = 1; in automute_mode_put()
4680 spec->automute_lo = 0; in automute_mode_put()
4681 } else if (spec->automute_lo_possible) { in automute_mode_put()
4682 if (spec->automute_lo) in automute_mode_put()
4684 spec->automute_lo = 1; in automute_mode_put()
4686 return -EINVAL; in automute_mode_put()
4689 if (!spec->automute_lo_possible || !spec->automute_speaker_possible) in automute_mode_put()
4690 return -EINVAL; in automute_mode_put()
4691 if (spec->automute_speaker && spec->automute_lo) in automute_mode_put()
4693 spec->automute_speaker = 1; in automute_mode_put()
4694 spec->automute_lo = 1; in automute_mode_put()
4697 return -EINVAL; in automute_mode_put()
4705 .name = "Auto-Mute Mode",
4713 struct hda_gen_spec *spec = codec->spec; in add_automute_mode_enum()
4716 return -ENOMEM; in add_automute_mode_enum()
4721 * Check the availability of HP/line-out auto-mute;
4726 struct hda_gen_spec *spec = codec->spec; in check_auto_mute_availability()
4727 struct auto_pin_cfg *cfg = &spec->autocfg; in check_auto_mute_availability()
4731 if (spec->suppress_auto_mute) in check_auto_mute_availability()
4734 if (cfg->hp_pins[0]) in check_auto_mute_availability()
4736 if (cfg->line_out_pins[0]) in check_auto_mute_availability()
4738 if (cfg->speaker_pins[0]) in check_auto_mute_availability()
4743 if (!cfg->speaker_pins[0] && in check_auto_mute_availability()
4744 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { in check_auto_mute_availability()
4745 memcpy(cfg->speaker_pins, cfg->line_out_pins, in check_auto_mute_availability()
4746 sizeof(cfg->speaker_pins)); in check_auto_mute_availability()
4747 cfg->speaker_outs = cfg->line_outs; in check_auto_mute_availability()
4750 if (!cfg->hp_pins[0] && in check_auto_mute_availability()
4751 cfg->line_out_type == AUTO_PIN_HP_OUT) { in check_auto_mute_availability()
4752 memcpy(cfg->hp_pins, cfg->line_out_pins, in check_auto_mute_availability()
4753 sizeof(cfg->hp_pins)); in check_auto_mute_availability()
4754 cfg->hp_outs = cfg->line_outs; in check_auto_mute_availability()
4757 for (i = 0; i < cfg->hp_outs; i++) { in check_auto_mute_availability()
4758 hda_nid_t nid = cfg->hp_pins[i]; in check_auto_mute_availability()
4761 codec_dbg(codec, "Enable HP auto-muting on NID 0x%x\n", nid); in check_auto_mute_availability()
4764 spec->detect_hp = 1; in check_auto_mute_availability()
4767 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { in check_auto_mute_availability()
4768 if (cfg->speaker_outs) in check_auto_mute_availability()
4769 for (i = 0; i < cfg->line_outs; i++) { in check_auto_mute_availability()
4770 hda_nid_t nid = cfg->line_out_pins[i]; in check_auto_mute_availability()
4773 codec_dbg(codec, "Enable Line-Out auto-muting on NID 0x%x\n", nid); in check_auto_mute_availability()
4776 spec->detect_lo = 1; in check_auto_mute_availability()
4778 spec->automute_lo_possible = spec->detect_hp; in check_auto_mute_availability()
4781 spec->automute_speaker_possible = cfg->speaker_outs && in check_auto_mute_availability()
4782 (spec->detect_hp || spec->detect_lo); in check_auto_mute_availability()
4784 spec->automute_lo = spec->automute_lo_possible; in check_auto_mute_availability()
4785 spec->automute_speaker = spec->automute_speaker_possible; in check_auto_mute_availability()
4787 if (spec->automute_speaker_possible || spec->automute_lo_possible) { in check_auto_mute_availability()
4796 /* check whether all auto-mic pins are valid; setup indices if OK */
4799 struct hda_gen_spec *spec = codec->spec; in auto_mic_check_imux()
4803 imux = &spec->input_mux; in auto_mic_check_imux()
4804 for (i = 0; i < spec->am_num_entries; i++) { in auto_mic_check_imux()
4805 spec->am_entry[i].idx = in auto_mic_check_imux()
4806 find_idx_in_nid_list(spec->am_entry[i].pin, in auto_mic_check_imux()
4807 spec->imux_pins, imux->num_items); in auto_mic_check_imux()
4808 if (spec->am_entry[i].idx < 0) in auto_mic_check_imux()
4812 /* we don't need the jack detection for the first pin */ in auto_mic_check_imux()
4813 for (i = 1; i < spec->am_num_entries; i++) in auto_mic_check_imux()
4815 spec->am_entry[i].pin, in auto_mic_check_imux()
4824 return (int)(a->attr - b->attr); in compare_attr()
4828 * Check the availability of auto-mic switch;
4833 struct hda_gen_spec *spec = codec->spec; in check_auto_mic_availability()
4834 struct auto_pin_cfg *cfg = &spec->autocfg; in check_auto_mic_availability()
4838 if (spec->suppress_auto_mic) in check_auto_mic_availability()
4843 for (i = 0; i < cfg->num_inputs; i++) { in check_auto_mic_availability()
4844 hda_nid_t nid = cfg->inputs[i].pin; in check_auto_mic_availability()
4852 if (cfg->inputs[i].type != AUTO_PIN_MIC) in check_auto_mic_availability()
4858 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) in check_auto_mic_availability()
4860 if (!spec->line_in_auto_switch && in check_auto_mic_availability()
4861 cfg->inputs[i].type != AUTO_PIN_MIC) in check_auto_mic_availability()
4870 spec->am_entry[num_pins].pin = nid; in check_auto_mic_availability()
4871 spec->am_entry[num_pins].attr = attr; in check_auto_mic_availability()
4878 spec->am_num_entries = num_pins; in check_auto_mic_availability()
4879 /* sort the am_entry in the order of attr so that the pin with a in check_auto_mic_availability()
4882 sort(spec->am_entry, num_pins, sizeof(spec->am_entry[0]), in check_auto_mic_availability()
4888 spec->auto_mic = 1; in check_auto_mic_availability()
4889 spec->num_adc_nids = 1; in check_auto_mic_availability()
4890 spec->cur_mux[0] = spec->am_entry[0].idx; in check_auto_mic_availability()
4891 codec_dbg(codec, "Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", in check_auto_mic_availability()
4892 spec->am_entry[0].pin, in check_auto_mic_availability()
4893 spec->am_entry[1].pin, in check_auto_mic_availability()
4894 spec->am_entry[2].pin); in check_auto_mic_availability()
4900 * snd_hda_gen_path_power_filter - power_filter hook to make inactive widgets
4910 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_path_power_filter()
4912 if (!spec->power_down_unused && !codec->power_save_node) in snd_hda_gen_path_power_filter()
4914 if (power_state != AC_PWRST_D0 || nid == codec->core.afg) in snd_hda_gen_path_power_filter()
4944 * snd_hda_gen_stream_pm - Stream power management callback
4953 if (codec->power_save_node) in snd_hda_gen_stream_pm()
4954 set_path_power(codec, nid, -1, on); in snd_hda_gen_stream_pm()
4978 * snd_hda_gen_shutup_speakers - Forcibly mute the speaker outputs
4990 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_shutup_speakers()
4997 if (!snd_hdac_is_power_on(&codec->core)) in snd_hda_gen_shutup_speakers()
5000 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) { in snd_hda_gen_shutup_speakers()
5001 paths = spec->out_paths; in snd_hda_gen_shutup_speakers()
5002 num_paths = spec->autocfg.line_outs; in snd_hda_gen_shutup_speakers()
5004 paths = spec->speaker_paths; in snd_hda_gen_shutup_speakers()
5005 num_paths = spec->autocfg.speaker_outs; in snd_hda_gen_shutup_speakers()
5012 for (p = 0; p < path->depth; p++) in snd_hda_gen_shutup_speakers()
5013 if (force_mute_output_path(codec, path->path[p])) in snd_hda_gen_shutup_speakers()
5022 * snd_hda_gen_parse_auto_config - Parse the given BIOS configuration and
5025 * @cfg: Parsed pin configuration
5033 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_parse_auto_config()
5038 if (spec->vmaster_mute_led || spec->mic_mute_led) in snd_hda_gen_parse_auto_config()
5041 if (spec->mixer_nid && !spec->mixer_merge_nid) in snd_hda_gen_parse_auto_config()
5042 spec->mixer_merge_nid = spec->mixer_nid; in snd_hda_gen_parse_auto_config()
5044 if (cfg != &spec->autocfg) { in snd_hda_gen_parse_auto_config()
5045 spec->autocfg = *cfg; in snd_hda_gen_parse_auto_config()
5046 cfg = &spec->autocfg; in snd_hda_gen_parse_auto_config()
5049 if (!spec->main_out_badness) in snd_hda_gen_parse_auto_config()
5050 spec->main_out_badness = &hda_main_out_badness; in snd_hda_gen_parse_auto_config()
5051 if (!spec->extra_out_badness) in snd_hda_gen_parse_auto_config()
5052 spec->extra_out_badness = &hda_extra_out_badness; in snd_hda_gen_parse_auto_config()
5056 if (!cfg->line_outs) { in snd_hda_gen_parse_auto_config()
5057 if (cfg->dig_outs || cfg->dig_in_pin) { in snd_hda_gen_parse_auto_config()
5058 spec->multiout.max_channels = 2; in snd_hda_gen_parse_auto_config()
5059 spec->no_analog = 1; in snd_hda_gen_parse_auto_config()
5062 if (!cfg->num_inputs && !cfg->dig_in_pin) in snd_hda_gen_parse_auto_config()
5063 return 0; /* can't find valid BIOS pin config */ in snd_hda_gen_parse_auto_config()
5066 if (!spec->no_primary_hp && in snd_hda_gen_parse_auto_config()
5067 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && in snd_hda_gen_parse_auto_config()
5068 cfg->line_outs <= cfg->hp_outs) { in snd_hda_gen_parse_auto_config()
5070 cfg->speaker_outs = cfg->line_outs; in snd_hda_gen_parse_auto_config()
5071 memcpy(cfg->speaker_pins, cfg->line_out_pins, in snd_hda_gen_parse_auto_config()
5072 sizeof(cfg->speaker_pins)); in snd_hda_gen_parse_auto_config()
5073 cfg->line_outs = cfg->hp_outs; in snd_hda_gen_parse_auto_config()
5074 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); in snd_hda_gen_parse_auto_config()
5075 cfg->hp_outs = 0; in snd_hda_gen_parse_auto_config()
5076 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); in snd_hda_gen_parse_auto_config()
5077 cfg->line_out_type = AUTO_PIN_HP_OUT; in snd_hda_gen_parse_auto_config()
5108 /* add power-down pin callbacks at first */ in snd_hda_gen_parse_auto_config()
5111 spec->const_channel_count = spec->ext_channel_count; in snd_hda_gen_parse_auto_config()
5113 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) in snd_hda_gen_parse_auto_config()
5114 spec->const_channel_count = max(spec->const_channel_count, in snd_hda_gen_parse_auto_config()
5115 cfg->speaker_outs * 2); in snd_hda_gen_parse_auto_config()
5116 if (cfg->line_out_type != AUTO_PIN_HP_OUT) in snd_hda_gen_parse_auto_config()
5117 spec->const_channel_count = max(spec->const_channel_count, in snd_hda_gen_parse_auto_config()
5118 cfg->hp_outs * 2); in snd_hda_gen_parse_auto_config()
5119 spec->multiout.max_channels = max(spec->ext_channel_count, in snd_hda_gen_parse_auto_config()
5120 spec->const_channel_count); in snd_hda_gen_parse_auto_config()
5135 if (!spec->auto_mic && spec->mixer_nid && in snd_hda_gen_parse_auto_config()
5136 spec->add_stereo_mix_input == HDA_HINT_STEREO_MIX_AUTO && in snd_hda_gen_parse_auto_config()
5137 spec->input_mux.num_items > 1) { in snd_hda_gen_parse_auto_config()
5138 err = parse_capture_source(codec, spec->mixer_nid, in snd_hda_gen_parse_auto_config()
5139 CFG_IDX_MIX, spec->num_all_adcs, in snd_hda_gen_parse_auto_config()
5157 if (spec->hp_mic_pin && in snd_hda_gen_parse_auto_config()
5158 (spec->auto_mic || spec->input_mux.num_items == 1 || in snd_hda_gen_parse_auto_config()
5159 spec->add_jack_modes)) { in snd_hda_gen_parse_auto_config()
5160 err = create_hp_mic_jack_mode(codec, spec->hp_mic_pin); in snd_hda_gen_parse_auto_config()
5165 if (spec->add_jack_modes) { in snd_hda_gen_parse_auto_config()
5166 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { in snd_hda_gen_parse_auto_config()
5167 err = create_out_jack_modes(codec, cfg->line_outs, in snd_hda_gen_parse_auto_config()
5168 cfg->line_out_pins); in snd_hda_gen_parse_auto_config()
5172 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { in snd_hda_gen_parse_auto_config()
5173 err = create_out_jack_modes(codec, cfg->hp_outs, in snd_hda_gen_parse_auto_config()
5174 cfg->hp_pins); in snd_hda_gen_parse_auto_config()
5180 /* add power-up pin callbacks at last */ in snd_hda_gen_parse_auto_config()
5184 if (spec->mixer_nid) in snd_hda_gen_parse_auto_config()
5185 mute_all_mixer_nid(codec, spec->mixer_nid); in snd_hda_gen_parse_auto_config()
5190 if (spec->power_down_unused || codec->power_save_node) { in snd_hda_gen_parse_auto_config()
5191 if (!codec->power_filter) in snd_hda_gen_parse_auto_config()
5192 codec->power_filter = snd_hda_gen_path_power_filter; in snd_hda_gen_parse_auto_config()
5193 if (!codec->patch_ops.stream_pm) in snd_hda_gen_parse_auto_config()
5194 codec->patch_ops.stream_pm = snd_hda_gen_stream_pm; in snd_hda_gen_parse_auto_config()
5197 if (!spec->no_analog && spec->beep_nid) { in snd_hda_gen_parse_auto_config()
5198 err = snd_hda_attach_beep_device(codec, spec->beep_nid); in snd_hda_gen_parse_auto_config()
5201 if (codec->beep && codec->power_save_node) { in snd_hda_gen_parse_auto_config()
5205 codec->beep->power_hook = beep_power_hook; in snd_hda_gen_parse_auto_config()
5230 * snd_hda_gen_build_controls - Build controls from the parsed results
5237 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_build_controls()
5240 if (spec->kctls.used) { in snd_hda_gen_build_controls()
5241 err = snd_hda_add_new_ctls(codec, spec->kctls.list); in snd_hda_gen_build_controls()
5246 if (spec->multiout.dig_out_nid) { in snd_hda_gen_build_controls()
5248 spec->multiout.dig_out_nid, in snd_hda_gen_build_controls()
5249 spec->multiout.dig_out_nid, in snd_hda_gen_build_controls()
5250 spec->pcm_rec[1]->pcm_type); in snd_hda_gen_build_controls()
5253 if (!spec->no_analog) { in snd_hda_gen_build_controls()
5255 &spec->multiout); in snd_hda_gen_build_controls()
5258 spec->multiout.share_spdif = 1; in snd_hda_gen_build_controls()
5261 if (spec->dig_in_nid) { in snd_hda_gen_build_controls()
5262 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); in snd_hda_gen_build_controls()
5268 if (!spec->no_analog && !spec->suppress_vmaster && in snd_hda_gen_build_controls()
5271 spec->vmaster_tlv, follower_pfxs, in snd_hda_gen_build_controls()
5276 if (!spec->no_analog && !spec->suppress_vmaster && in snd_hda_gen_build_controls()
5281 spec->vmaster_mute_led ? in snd_hda_gen_build_controls()
5283 &spec->vmaster_mute.sw_kctl); in snd_hda_gen_build_controls()
5286 if (spec->vmaster_mute.hook) { in snd_hda_gen_build_controls()
5287 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute); in snd_hda_gen_build_controls()
5288 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); in snd_hda_gen_build_controls()
5294 err = snd_hda_jack_add_kctls(codec, &spec->autocfg); in snd_hda_gen_build_controls()
5312 struct hda_gen_spec *spec = codec->spec; in call_pcm_playback_hook()
5313 if (spec->pcm_playback_hook) in call_pcm_playback_hook()
5314 spec->pcm_playback_hook(hinfo, codec, substream, action); in call_pcm_playback_hook()
5322 struct hda_gen_spec *spec = codec->spec; in call_pcm_capture_hook()
5323 if (spec->pcm_capture_hook) in call_pcm_capture_hook()
5324 spec->pcm_capture_hook(hinfo, codec, substream, action); in call_pcm_capture_hook()
5334 struct hda_gen_spec *spec = codec->spec; in playback_pcm_open()
5337 mutex_lock(&spec->pcm_mutex); in playback_pcm_open()
5339 &spec->multiout, substream, in playback_pcm_open()
5342 spec->active_streams |= 1 << STREAM_MULTI_OUT; in playback_pcm_open()
5346 mutex_unlock(&spec->pcm_mutex); in playback_pcm_open()
5356 struct hda_gen_spec *spec = codec->spec; in playback_pcm_prepare()
5359 err = snd_hda_multi_out_analog_prepare(codec, &spec->multiout, in playback_pcm_prepare()
5371 struct hda_gen_spec *spec = codec->spec; in playback_pcm_cleanup()
5374 err = snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); in playback_pcm_cleanup()
5385 struct hda_gen_spec *spec = codec->spec; in playback_pcm_close()
5386 mutex_lock(&spec->pcm_mutex); in playback_pcm_close()
5387 spec->active_streams &= ~(1 << STREAM_MULTI_OUT); in playback_pcm_close()
5390 mutex_unlock(&spec->pcm_mutex); in playback_pcm_close()
5408 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in capture_pcm_prepare()
5418 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in capture_pcm_cleanup()
5436 struct hda_gen_spec *spec = codec->spec; in alt_playback_pcm_open()
5439 mutex_lock(&spec->pcm_mutex); in alt_playback_pcm_open()
5440 if (spec->indep_hp && !spec->indep_hp_enabled) in alt_playback_pcm_open()
5441 err = -EBUSY; in alt_playback_pcm_open()
5443 spec->active_streams |= 1 << STREAM_INDEP_HP; in alt_playback_pcm_open()
5446 mutex_unlock(&spec->pcm_mutex); in alt_playback_pcm_open()
5454 struct hda_gen_spec *spec = codec->spec; in alt_playback_pcm_close()
5455 mutex_lock(&spec->pcm_mutex); in alt_playback_pcm_close()
5456 spec->active_streams &= ~(1 << STREAM_INDEP_HP); in alt_playback_pcm_close()
5459 mutex_unlock(&spec->pcm_mutex); in alt_playback_pcm_close()
5469 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in alt_playback_pcm_prepare()
5479 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in alt_playback_pcm_cleanup()
5492 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_open()
5493 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in dig_playback_pcm_open()
5502 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_prepare()
5503 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in dig_playback_pcm_prepare()
5511 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_cleanup()
5512 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); in dig_playback_pcm_cleanup()
5519 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_close()
5520 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in dig_playback_pcm_close()
5535 struct hda_gen_spec *spec = codec->spec; in alt_capture_pcm_prepare()
5537 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], in alt_capture_pcm_prepare()
5548 struct hda_gen_spec *spec = codec->spec; in alt_capture_pcm_cleanup()
5551 spec->adc_nids[substream->number + 1]); in alt_capture_pcm_cleanup()
5643 struct hda_gen_spec *spec = codec->spec; in dyn_adc_pcm_resetup()
5644 hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; in dyn_adc_pcm_resetup()
5646 if (spec->cur_adc && spec->cur_adc != new_adc) { in dyn_adc_pcm_resetup()
5648 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); in dyn_adc_pcm_resetup()
5649 spec->cur_adc = new_adc; in dyn_adc_pcm_resetup()
5651 spec->cur_adc_stream_tag, 0, in dyn_adc_pcm_resetup()
5652 spec->cur_adc_format); in dyn_adc_pcm_resetup()
5658 /* analog capture with dynamic dual-adc changes */
5665 struct hda_gen_spec *spec = codec->spec; in dyn_adc_capture_pcm_prepare()
5666 spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]]; in dyn_adc_capture_pcm_prepare()
5667 spec->cur_adc_stream_tag = stream_tag; in dyn_adc_capture_pcm_prepare()
5668 spec->cur_adc_format = format; in dyn_adc_capture_pcm_prepare()
5669 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); in dyn_adc_capture_pcm_prepare()
5678 struct hda_gen_spec *spec = codec->spec; in dyn_adc_capture_pcm_cleanup()
5679 snd_hda_codec_cleanup_stream(codec, spec->cur_adc); in dyn_adc_capture_pcm_cleanup()
5680 spec->cur_adc = 0; in dyn_adc_capture_pcm_cleanup()
5705 /* drop non-alnum chars after a space */ in fill_pcm_stream_name()
5715 /* copy PCM stream info from @default_str, and override non-NULL entries
5725 str->nid = nid; in setup_pcm_stream()
5727 if (spec_str->substreams) in setup_pcm_stream()
5728 str->substreams = spec_str->substreams; in setup_pcm_stream()
5729 if (spec_str->channels_min) in setup_pcm_stream()
5730 str->channels_min = spec_str->channels_min; in setup_pcm_stream()
5731 if (spec_str->channels_max) in setup_pcm_stream()
5732 str->channels_max = spec_str->channels_max; in setup_pcm_stream()
5733 if (spec_str->rates) in setup_pcm_stream()
5734 str->rates = spec_str->rates; in setup_pcm_stream()
5735 if (spec_str->formats) in setup_pcm_stream()
5736 str->formats = spec_str->formats; in setup_pcm_stream()
5737 if (spec_str->maxbps) in setup_pcm_stream()
5738 str->maxbps = spec_str->maxbps; in setup_pcm_stream()
5743 * snd_hda_gen_build_pcms - build PCM streams based on the parsed results
5750 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_build_pcms()
5754 if (spec->no_analog) in snd_hda_gen_build_pcms()
5757 fill_pcm_stream_name(spec->stream_name_analog, in snd_hda_gen_build_pcms()
5758 sizeof(spec->stream_name_analog), in snd_hda_gen_build_pcms()
5759 " Analog", codec->core.chip_name); in snd_hda_gen_build_pcms()
5760 info = snd_hda_codec_pcm_new(codec, "%s", spec->stream_name_analog); in snd_hda_gen_build_pcms()
5762 return -ENOMEM; in snd_hda_gen_build_pcms()
5763 spec->pcm_rec[0] = info; in snd_hda_gen_build_pcms()
5765 if (spec->multiout.num_dacs > 0) { in snd_hda_gen_build_pcms()
5766 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5768 spec->stream_analog_playback, in snd_hda_gen_build_pcms()
5769 spec->multiout.dac_nids[0]); in snd_hda_gen_build_pcms()
5770 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = in snd_hda_gen_build_pcms()
5771 spec->multiout.max_channels; in snd_hda_gen_build_pcms()
5772 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && in snd_hda_gen_build_pcms()
5773 spec->autocfg.line_outs == 2) in snd_hda_gen_build_pcms()
5774 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = in snd_hda_gen_build_pcms()
5777 if (spec->num_adc_nids) { in snd_hda_gen_build_pcms()
5778 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5779 (spec->dyn_adc_switch ? in snd_hda_gen_build_pcms()
5781 spec->stream_analog_capture, in snd_hda_gen_build_pcms()
5782 spec->adc_nids[0]); in snd_hda_gen_build_pcms()
5787 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { in snd_hda_gen_build_pcms()
5788 fill_pcm_stream_name(spec->stream_name_digital, in snd_hda_gen_build_pcms()
5789 sizeof(spec->stream_name_digital), in snd_hda_gen_build_pcms()
5790 " Digital", codec->core.chip_name); in snd_hda_gen_build_pcms()
5792 spec->stream_name_digital); in snd_hda_gen_build_pcms()
5794 return -ENOMEM; in snd_hda_gen_build_pcms()
5795 codec->follower_dig_outs = spec->multiout.follower_dig_outs; in snd_hda_gen_build_pcms()
5796 spec->pcm_rec[1] = info; in snd_hda_gen_build_pcms()
5797 if (spec->dig_out_type) in snd_hda_gen_build_pcms()
5798 info->pcm_type = spec->dig_out_type; in snd_hda_gen_build_pcms()
5800 info->pcm_type = HDA_PCM_TYPE_SPDIF; in snd_hda_gen_build_pcms()
5801 if (spec->multiout.dig_out_nid) in snd_hda_gen_build_pcms()
5802 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5804 spec->stream_digital_playback, in snd_hda_gen_build_pcms()
5805 spec->multiout.dig_out_nid); in snd_hda_gen_build_pcms()
5806 if (spec->dig_in_nid) in snd_hda_gen_build_pcms()
5807 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5809 spec->stream_digital_capture, in snd_hda_gen_build_pcms()
5810 spec->dig_in_nid); in snd_hda_gen_build_pcms()
5813 if (spec->no_analog) in snd_hda_gen_build_pcms()
5817 * model, configure a second analog capture-only PCM. in snd_hda_gen_build_pcms()
5819 have_multi_adcs = (spec->num_adc_nids > 1) && in snd_hda_gen_build_pcms()
5820 !spec->dyn_adc_switch && !spec->auto_mic; in snd_hda_gen_build_pcms()
5822 if (spec->alt_dac_nid || have_multi_adcs) { in snd_hda_gen_build_pcms()
5823 fill_pcm_stream_name(spec->stream_name_alt_analog, in snd_hda_gen_build_pcms()
5824 sizeof(spec->stream_name_alt_analog), in snd_hda_gen_build_pcms()
5825 " Alt Analog", codec->core.chip_name); in snd_hda_gen_build_pcms()
5827 spec->stream_name_alt_analog); in snd_hda_gen_build_pcms()
5829 return -ENOMEM; in snd_hda_gen_build_pcms()
5830 spec->pcm_rec[2] = info; in snd_hda_gen_build_pcms()
5831 if (spec->alt_dac_nid) in snd_hda_gen_build_pcms()
5832 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5834 spec->stream_analog_alt_playback, in snd_hda_gen_build_pcms()
5835 spec->alt_dac_nid); in snd_hda_gen_build_pcms()
5837 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_PLAYBACK], in snd_hda_gen_build_pcms()
5840 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5842 spec->stream_analog_alt_capture, in snd_hda_gen_build_pcms()
5843 spec->adc_nids[1]); in snd_hda_gen_build_pcms()
5844 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = in snd_hda_gen_build_pcms()
5845 spec->num_adc_nids - 1; in snd_hda_gen_build_pcms()
5847 setup_pcm_stream(&info->stream[SNDRV_PCM_STREAM_CAPTURE], in snd_hda_gen_build_pcms()
5858 * Standard auto-parser initializations
5865 hda_nid_t pin; in set_output_and_unmute() local
5868 if (!path || !path->depth) in set_output_and_unmute()
5870 pin = path->path[path->depth - 1]; in set_output_and_unmute()
5871 restore_pin_ctl(codec, pin); in set_output_and_unmute()
5872 snd_hda_activate_path(codec, path, path->active, in set_output_and_unmute()
5873 aamix_default(codec->spec)); in set_output_and_unmute()
5874 set_pin_eapd(codec, pin, path->active); in set_output_and_unmute()
5880 struct hda_gen_spec *spec = codec->spec; in init_multi_out()
5883 for (i = 0; i < spec->autocfg.line_outs; i++) in init_multi_out()
5884 set_output_and_unmute(codec, spec->out_paths[i]); in init_multi_out()
5899 struct hda_gen_spec *spec = codec->spec; in init_extra_out()
5901 if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) in init_extra_out()
5902 __init_extra_out(codec, spec->autocfg.hp_outs, spec->hp_paths); in init_extra_out()
5903 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) in init_extra_out()
5904 __init_extra_out(codec, spec->autocfg.speaker_outs, in init_extra_out()
5905 spec->speaker_paths); in init_extra_out()
5908 /* initialize multi-io paths */
5911 struct hda_gen_spec *spec = codec->spec; in init_multi_io()
5914 for (i = 0; i < spec->multi_ios; i++) { in init_multi_io()
5915 hda_nid_t pin = spec->multi_io[i].pin; in init_multi_io() local
5920 if (!spec->multi_io[i].ctl_in) in init_multi_io()
5921 spec->multi_io[i].ctl_in = in init_multi_io()
5922 snd_hda_codec_get_pin_target(codec, pin); in init_multi_io()
5923 snd_hda_activate_path(codec, path, path->active, in init_multi_io()
5930 struct hda_gen_spec *spec = codec->spec; in init_aamix_paths()
5932 if (!spec->have_aamix_ctl) in init_aamix_paths()
5936 update_aamix_paths(codec, spec->aamix_mode, spec->out_paths[0], in init_aamix_paths()
5937 spec->aamix_out_paths[0], in init_aamix_paths()
5938 spec->autocfg.line_out_type); in init_aamix_paths()
5939 update_aamix_paths(codec, spec->aamix_mode, spec->hp_paths[0], in init_aamix_paths()
5940 spec->aamix_out_paths[1], in init_aamix_paths()
5942 update_aamix_paths(codec, spec->aamix_mode, spec->speaker_paths[0], in init_aamix_paths()
5943 spec->aamix_out_paths[2], in init_aamix_paths()
5950 struct hda_gen_spec *spec = codec->spec; in init_analog_input()
5951 struct auto_pin_cfg *cfg = &spec->autocfg; in init_analog_input()
5954 for (i = 0; i < cfg->num_inputs; i++) { in init_analog_input()
5955 hda_nid_t nid = cfg->inputs[i].pin; in init_analog_input()
5960 if (spec->mixer_nid) { in init_analog_input()
5961 resume_path_from_idx(codec, spec->loopback_paths[i]); in init_analog_input()
5962 resume_path_from_idx(codec, spec->loopback_merge_path); in init_analog_input()
5970 struct hda_gen_spec *spec = codec->spec; in init_input_src()
5971 struct hda_input_mux *imux = &spec->input_mux; in init_input_src()
5975 if (spec->dyn_adc_switch) in init_input_src()
5978 nums = spec->num_adc_nids; in init_input_src()
5981 for (i = 0; i < imux->num_items; i++) { in init_input_src()
5984 bool active = path->active; in init_input_src()
5985 if (i == spec->cur_mux[c]) in init_input_src()
5990 if (spec->hp_mic) in init_input_src()
5994 if (spec->cap_sync_hook) in init_input_src()
5995 spec->cap_sync_hook(codec, NULL, NULL); in init_input_src()
5998 /* set right pin controls for digital I/O */
6001 struct hda_gen_spec *spec = codec->spec; in init_digital()
6003 hda_nid_t pin; in init_digital() local
6005 for (i = 0; i < spec->autocfg.dig_outs; i++) in init_digital()
6006 set_output_and_unmute(codec, spec->digout_paths[i]); in init_digital()
6007 pin = spec->autocfg.dig_in_pin; in init_digital()
6008 if (pin) { in init_digital()
6009 restore_pin_ctl(codec, pin); in init_digital()
6010 resume_path_from_idx(codec, spec->digin_path); in init_digital()
6014 /* clear unsol-event tags on unused pins; Conexant codecs seem to leave
6019 const struct hda_pincfg *pin; in clear_unsol_on_unused_pins() local
6022 snd_array_for_each(&codec->init_pins, i, pin) { in clear_unsol_on_unused_pins()
6023 hda_nid_t nid = pin->nid; in clear_unsol_on_unused_pins()
6032 * snd_hda_gen_init - initialize the generic spec
6039 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_init()
6041 if (spec->init_hook) in snd_hda_gen_init()
6042 spec->init_hook(codec); in snd_hda_gen_init()
6044 if (!spec->skip_verbs) in snd_hda_gen_init()
6059 /* call init functions of standard auto-mute helpers */ in snd_hda_gen_init()
6064 if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook) in snd_hda_gen_init()
6065 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); in snd_hda_gen_init()
6073 * snd_hda_gen_free - free the generic spec
6081 snd_hda_gen_spec_free(codec->spec); in snd_hda_gen_free()
6082 kfree(codec->spec); in snd_hda_gen_free()
6083 codec->spec = NULL; in snd_hda_gen_free()
6088 * snd_hda_gen_check_power_status - check the loopback power save state
6096 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_check_power_status()
6097 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); in snd_hda_gen_check_power_status()
6116 * snd_hda_parse_generic_codec - Generic codec parser
6126 return -ENOMEM; in snd_hda_parse_generic_codec()
6128 codec->spec = spec; in snd_hda_parse_generic_codec()
6130 err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0); in snd_hda_parse_generic_codec()
6134 err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg); in snd_hda_parse_generic_codec()
6138 codec->patch_ops = generic_patch_ops; in snd_hda_parse_generic_codec()
6159 MODULE_DESCRIPTION("Generic HD-audio codec parser");