Lines Matching refs:codec

111 static void parse_user_hints(struct hda_codec *codec)  in parse_user_hints()  argument
113 struct hda_gen_spec *spec = codec->spec; in parse_user_hints()
116 val = snd_hda_get_bool_hint(codec, "jack_detect"); in parse_user_hints()
118 codec->no_jack_detect = !val; in parse_user_hints()
119 val = snd_hda_get_bool_hint(codec, "inv_jack_detect"); in parse_user_hints()
121 codec->inv_jack_detect = !!val; in parse_user_hints()
122 val = snd_hda_get_bool_hint(codec, "trigger_sense"); in parse_user_hints()
124 codec->no_trigger_sense = !val; in parse_user_hints()
125 val = snd_hda_get_bool_hint(codec, "inv_eapd"); in parse_user_hints()
127 codec->inv_eapd = !!val; in parse_user_hints()
128 val = snd_hda_get_bool_hint(codec, "pcm_format_first"); in parse_user_hints()
130 codec->pcm_format_first = !!val; in parse_user_hints()
131 val = snd_hda_get_bool_hint(codec, "sticky_stream"); in parse_user_hints()
133 codec->no_sticky_stream = !val; in parse_user_hints()
134 val = snd_hda_get_bool_hint(codec, "spdif_status_reset"); in parse_user_hints()
136 codec->spdif_status_reset = !!val; in parse_user_hints()
137 val = snd_hda_get_bool_hint(codec, "pin_amp_workaround"); in parse_user_hints()
139 codec->pin_amp_workaround = !!val; in parse_user_hints()
140 val = snd_hda_get_bool_hint(codec, "single_adc_amp"); in parse_user_hints()
142 codec->single_adc_amp = !!val; in parse_user_hints()
143 val = snd_hda_get_bool_hint(codec, "power_save_node"); in parse_user_hints()
145 codec->power_save_node = !!val; in parse_user_hints()
147 val = snd_hda_get_bool_hint(codec, "auto_mute"); in parse_user_hints()
150 val = snd_hda_get_bool_hint(codec, "auto_mic"); in parse_user_hints()
153 val = snd_hda_get_bool_hint(codec, "line_in_auto_switch"); in parse_user_hints()
156 val = snd_hda_get_bool_hint(codec, "auto_mute_via_amp"); in parse_user_hints()
159 val = snd_hda_get_bool_hint(codec, "need_dac_fix"); in parse_user_hints()
162 val = snd_hda_get_bool_hint(codec, "primary_hp"); in parse_user_hints()
165 val = snd_hda_get_bool_hint(codec, "multi_io"); in parse_user_hints()
168 val = snd_hda_get_bool_hint(codec, "multi_cap_vol"); in parse_user_hints()
171 val = snd_hda_get_bool_hint(codec, "inv_dmic_split"); in parse_user_hints()
174 val = snd_hda_get_bool_hint(codec, "indep_hp"); in parse_user_hints()
177 val = snd_hda_get_bool_hint(codec, "add_stereo_mix_input"); in parse_user_hints()
181 val = snd_hda_get_bool_hint(codec, "add_out_jack_modes"); in parse_user_hints()
184 val = snd_hda_get_bool_hint(codec, "add_in_jack_modes"); in parse_user_hints()
187 val = snd_hda_get_bool_hint(codec, "add_jack_modes"); in parse_user_hints()
190 val = snd_hda_get_bool_hint(codec, "power_down_unused"); in parse_user_hints()
193 val = snd_hda_get_bool_hint(codec, "add_hp_mic"); in parse_user_hints()
196 val = snd_hda_get_bool_hint(codec, "hp_mic_detect"); in parse_user_hints()
200 if (!snd_hda_get_int_hint(codec, "mixer_nid", &val)) in parse_user_hints()
208 #define update_pin_ctl(codec, pin, val) \ argument
209 snd_hda_codec_update_cache(codec, pin, 0, \
213 static inline void restore_pin_ctl(struct hda_codec *codec, hda_nid_t pin) in restore_pin_ctl() argument
215 update_pin_ctl(codec, pin, snd_hda_codec_get_pin_target(codec, pin)); in restore_pin_ctl()
219 static void set_pin_target(struct hda_codec *codec, hda_nid_t pin, in set_pin_target() argument
224 val = snd_hda_correct_pin_ctl(codec, pin, val); in set_pin_target()
225 snd_hda_codec_set_pin_target(codec, pin, val); in set_pin_target()
227 update_pin_ctl(codec, pin, val); in set_pin_target()
231 static void set_pin_targets(struct hda_codec *codec, int num_pins, in set_pin_targets() argument
236 set_pin_target(codec, pins[i], val, false); in set_pin_targets()
259 static struct nid_path *get_nid_path(struct hda_codec *codec, in get_nid_path() argument
263 struct hda_gen_spec *spec = codec->spec; in get_nid_path()
290 struct nid_path *snd_hda_get_nid_path(struct hda_codec *codec, in snd_hda_get_nid_path() argument
293 return get_nid_path(codec, from_nid, to_nid, 0); in snd_hda_get_nid_path()
306 int snd_hda_get_path_idx(struct hda_codec *codec, struct nid_path *path) in snd_hda_get_path_idx() argument
308 struct hda_gen_spec *spec = codec->spec; in snd_hda_get_path_idx()
327 struct nid_path *snd_hda_get_path_from_idx(struct hda_codec *codec, int idx) in snd_hda_get_path_from_idx() argument
329 struct hda_gen_spec *spec = codec->spec; in snd_hda_get_path_from_idx()
338 static bool is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) in is_dac_already_used() argument
340 struct hda_gen_spec *spec = codec->spec; in is_dac_already_used()
352 static bool is_reachable_path(struct hda_codec *codec, in is_reachable_path() argument
357 return snd_hda_get_conn_index(codec, to_nid, from_nid, true) >= 0; in is_reachable_path()
364 static bool is_ctl_used(struct hda_codec *codec, unsigned int val, int type) in is_ctl_used() argument
366 struct hda_gen_spec *spec = codec->spec; in is_ctl_used()
379 static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid, in is_ctl_associated() argument
383 return is_ctl_used(codec, val, type); in is_ctl_associated()
386 static void print_nid_path(struct hda_codec *codec, in print_nid_path() argument
399 codec_dbg(codec, "%s path: depth=%d '%s'\n", pfx, path->depth, buf); in print_nid_path()
403 static bool __parse_nid_path(struct hda_codec *codec, in __parse_nid_path() argument
416 nums = snd_hda_get_conn_list(codec, to_nid, &conn); in __parse_nid_path()
423 get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT || in __parse_nid_path()
424 is_dac_already_used(codec, conn[i])) in __parse_nid_path()
435 type = get_wcaps_type(get_wcaps(codec, conn[i])); in __parse_nid_path()
439 if (__parse_nid_path(codec, from_nid, conn[i], in __parse_nid_path()
448 if (nums > 1 && get_wcaps_type(get_wcaps(codec, to_nid)) != AC_WID_AUD_MIX) in __parse_nid_path()
473 bool snd_hda_parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, in snd_hda_parse_nid_path() argument
477 if (__parse_nid_path(codec, from_nid, to_nid, anchor_nid, path, 1)) { in snd_hda_parse_nid_path()
497 snd_hda_add_new_path(struct hda_codec *codec, hda_nid_t from_nid, in snd_hda_add_new_path() argument
500 struct hda_gen_spec *spec = codec->spec; in snd_hda_add_new_path()
503 if (from_nid && to_nid && !is_reachable_path(codec, from_nid, to_nid)) in snd_hda_add_new_path()
507 path = get_nid_path(codec, from_nid, to_nid, anchor_nid); in snd_hda_add_new_path()
515 if (snd_hda_parse_nid_path(codec, from_nid, to_nid, anchor_nid, path)) in snd_hda_add_new_path()
524 static void invalidate_nid_path(struct hda_codec *codec, int idx) in invalidate_nid_path() argument
526 struct nid_path *path = snd_hda_get_path_from_idx(codec, idx); in invalidate_nid_path()
533 static hda_nid_t get_preferred_dac(struct hda_codec *codec, hda_nid_t pin) in get_preferred_dac() argument
535 struct hda_gen_spec *spec = codec->spec; in get_preferred_dac()
547 static hda_nid_t look_for_dac(struct hda_codec *codec, hda_nid_t pin, in look_for_dac() argument
550 struct hda_gen_spec *spec = codec->spec; in look_for_dac()
556 if (!nid || is_dac_already_used(codec, nid)) in look_for_dac()
558 cap_digital = !!(get_wcaps(codec, nid) & AC_WCAP_DIGITAL); in look_for_dac()
561 if (is_reachable_path(codec, nid, pin)) in look_for_dac()
575 static bool same_amp_caps(struct hda_codec *codec, hda_nid_t nid1, in same_amp_caps() argument
578 if (!(get_wcaps(codec, nid1) & (1 << (dir + 1)))) in same_amp_caps()
579 return !(get_wcaps(codec, nid2) & (1 << (dir + 1))); in same_amp_caps()
580 return (query_amp_caps(codec, nid1, dir) == in same_amp_caps()
581 query_amp_caps(codec, nid2, dir)); in same_amp_caps()
585 static hda_nid_t look_for_out_mute_nid(struct hda_codec *codec, in look_for_out_mute_nid() argument
591 if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) in look_for_out_mute_nid()
594 nid_has_mute(codec, path->path[i], HDA_INPUT)) in look_for_out_mute_nid()
601 static hda_nid_t look_for_out_vol_nid(struct hda_codec *codec, in look_for_out_vol_nid() argument
604 struct hda_gen_spec *spec = codec->spec; in look_for_out_vol_nid()
611 if (nid_has_volume(codec, nid, HDA_OUTPUT)) in look_for_out_vol_nid()
622 static bool has_amp_in(struct hda_codec *codec, struct nid_path *path, int idx) in has_amp_in() argument
625 unsigned int caps = get_wcaps(codec, nid); in has_amp_in()
636 static bool has_amp_out(struct hda_codec *codec, struct nid_path *path, int idx) in has_amp_out() argument
639 unsigned int caps = get_wcaps(codec, nid); in has_amp_out()
650 static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid, in is_active_nid() argument
653 struct hda_gen_spec *spec = codec->spec; in is_active_nid()
654 int type = get_wcaps_type(get_wcaps(codec, nid)); in is_active_nid()
657 if (nid == codec->core.afg) in is_active_nid()
664 if (codec->power_save_node) { in is_active_nid()
685 #define is_active_nid_for_any(codec, nid) \ argument
686 is_active_nid(codec, nid, HDA_OUTPUT, -1)
689 static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, in get_amp_val_to_activate() argument
707 static bool is_stereo_amps(struct hda_codec *codec, hda_nid_t nid, int dir) in is_stereo_amps() argument
709 unsigned int wcaps = get_wcaps(codec, nid); in is_stereo_amps()
716 if (snd_hda_get_num_conns(codec, nid) != 1) in is_stereo_amps()
718 if (snd_hda_get_connections(codec, nid, &conn, 1) < 0) in is_stereo_amps()
720 return !!(get_wcaps(codec, conn) & AC_WCAP_STEREO); in is_stereo_amps()
724 static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) in init_amp() argument
726 unsigned int caps = query_amp_caps(codec, nid, dir); in init_amp()
727 int val = get_amp_val_to_activate(codec, nid, dir, caps, false); in init_amp()
729 if (is_stereo_amps(codec, nid, dir)) in init_amp()
730 snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); in init_amp()
732 snd_hda_codec_amp_init(codec, nid, 0, dir, idx, 0xff, val); in init_amp()
736 static int update_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx, in update_amp() argument
739 if (is_stereo_amps(codec, nid, dir)) in update_amp()
740 return snd_hda_codec_amp_stereo(codec, nid, dir, idx, in update_amp()
743 return snd_hda_codec_amp_update(codec, nid, 0, dir, idx, in update_amp()
750 static unsigned int get_amp_mask_to_modify(struct hda_codec *codec, in get_amp_mask_to_modify() argument
757 if (is_ctl_associated(codec, nid, dir, idx, NID_PATH_MUTE_CTL)) in get_amp_mask_to_modify()
761 if (is_ctl_associated(codec, nid, dir, idx, NID_PATH_VOL_CTL) || in get_amp_mask_to_modify()
762 is_ctl_associated(codec, nid, dir, idx, NID_PATH_BOOST_CTL)) in get_amp_mask_to_modify()
768 static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir, in activate_amp() argument
774 caps = query_amp_caps(codec, nid, dir); in activate_amp()
775 val = get_amp_val_to_activate(codec, nid, dir, caps, enable); in activate_amp()
776 mask = get_amp_mask_to_modify(codec, nid, dir, idx_to_check, caps); in activate_amp()
781 update_amp(codec, nid, dir, idx, mask, val); in activate_amp()
784 static void check_and_activate_amp(struct hda_codec *codec, hda_nid_t nid, in check_and_activate_amp() argument
789 if (!enable && is_active_nid(codec, nid, dir, idx_to_check)) in check_and_activate_amp()
791 activate_amp(codec, nid, dir, idx, idx_to_check, enable); in check_and_activate_amp()
794 static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, in activate_amp_out() argument
798 init_amp(codec, nid, HDA_OUTPUT, 0); in activate_amp_out()
799 check_and_activate_amp(codec, nid, HDA_OUTPUT, 0, 0, enable); in activate_amp_out()
802 static void activate_amp_in(struct hda_codec *codec, struct nid_path *path, in activate_amp_in() argument
805 struct hda_gen_spec *spec = codec->spec; in activate_amp_in()
811 nums = snd_hda_get_conn_list(codec, nid, &conn); in activate_amp_in()
812 type = get_wcaps_type(get_wcaps(codec, nid)); in activate_amp_in()
814 (type == AC_WID_AUD_IN && codec->single_adc_amp)) { in activate_amp_in()
821 init_amp(codec, nid, HDA_INPUT, n); in activate_amp_in()
832 activate_amp(codec, nid, HDA_INPUT, n, n, false); in activate_amp_in()
836 check_and_activate_amp(codec, nid, HDA_INPUT, n, idx, enable); in activate_amp_in()
841 static hda_nid_t path_power_update(struct hda_codec *codec, in path_power_update() argument
850 if (!(get_wcaps(codec, nid) & AC_WCAP_POWER)) in path_power_update()
852 if (nid == codec->core.afg) in path_power_update()
854 if (!allow_powerdown || is_active_nid_for_any(codec, nid)) in path_power_update()
858 power = snd_hda_codec_read(codec, nid, 0, in path_power_update()
861 snd_hda_codec_write(codec, nid, 0, in path_power_update()
872 snd_hdac_regmap_sync_node(&codec->core, nid); in path_power_update()
880 static void sync_power_state_change(struct hda_codec *codec, hda_nid_t nid) in sync_power_state_change() argument
884 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in sync_power_state_change()
897 void snd_hda_activate_path(struct hda_codec *codec, struct nid_path *path, in snd_hda_activate_path() argument
900 struct hda_gen_spec *spec = codec->spec; in snd_hda_activate_path()
906 if (enable && (spec->power_down_unused || codec->power_save_node)) in snd_hda_activate_path()
907 path_power_update(codec, path, codec->power_save_node); in snd_hda_activate_path()
913 snd_hda_codec_update_cache(codec, nid, 0, in snd_hda_activate_path()
916 if (has_amp_in(codec, path, i)) in snd_hda_activate_path()
917 activate_amp_in(codec, path, i, enable, add_aamix); in snd_hda_activate_path()
918 if (has_amp_out(codec, path, i)) in snd_hda_activate_path()
919 activate_amp_out(codec, path, i, enable); in snd_hda_activate_path()
925 static void path_power_down_sync(struct hda_codec *codec, struct nid_path *path) in path_power_down_sync() argument
927 struct hda_gen_spec *spec = codec->spec; in path_power_down_sync()
929 if (!(spec->power_down_unused || codec->power_save_node) || path->active) in path_power_down_sync()
931 sync_power_state_change(codec, path_power_update(codec, path, true)); in path_power_down_sync()
935 static void set_pin_eapd(struct hda_codec *codec, hda_nid_t pin, bool enable) in set_pin_eapd() argument
937 struct hda_gen_spec *spec = codec->spec; in set_pin_eapd()
939 !(snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD)) in set_pin_eapd()
943 if (codec->inv_eapd) in set_pin_eapd()
945 snd_hda_codec_update_cache(codec, pin, 0, in set_pin_eapd()
951 static void resume_path_from_idx(struct hda_codec *codec, int path_idx) in resume_path_from_idx() argument
953 struct nid_path *path = snd_hda_get_path_from_idx(codec, path_idx); in resume_path_from_idx()
955 snd_hda_activate_path(codec, path, path->active, false); in resume_path_from_idx()
1030 static int add_vol_ctl(struct hda_codec *codec, const char *pfx, int cidx, in add_vol_ctl() argument
1040 return __add_pb_vol_ctrl(codec->spec, HDA_CTL_WIDGET_VOL, pfx, cidx, val); in add_vol_ctl()
1044 static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path, in get_default_ch_nums() argument
1050 if (nid && (get_wcaps(codec, nid) & AC_WCAP_STEREO)) in get_default_ch_nums()
1056 static int add_stereo_vol(struct hda_codec *codec, const char *pfx, int cidx, in add_stereo_vol() argument
1059 int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL); in add_stereo_vol()
1060 return add_vol_ctl(codec, pfx, cidx, chs, path); in add_stereo_vol()
1066 static int add_sw_ctl(struct hda_codec *codec, const char *pfx, int cidx, in add_sw_ctl() argument
1080 int nums = snd_hda_get_num_conns(codec, nid); in add_sw_ctl()
1086 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); in add_sw_ctl()
1089 static int add_stereo_sw(struct hda_codec *codec, const char *pfx, in add_stereo_sw() argument
1092 int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL); in add_stereo_sw()
1093 return add_sw_ctl(codec, pfx, cidx, chs, path); in add_stereo_sw()
1100 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in sync_auto_mute_bits() local
1101 struct hda_gen_spec *spec = codec->spec; in sync_auto_mute_bits()
1126 static bool path_has_mixer(struct hda_codec *codec, int path_idx, int ctl_type) in path_has_mixer() argument
1128 struct nid_path *path = snd_hda_get_path_from_idx(codec, path_idx); in path_has_mixer()
1137 static const char *get_line_out_pfx(struct hda_codec *codec, int ch, in get_line_out_pfx() argument
1140 struct hda_gen_spec *spec = codec->spec; in get_line_out_pfx()
1165 !path_has_mixer(codec, spec->hp_paths[0], ctl_type)) in get_line_out_pfx()
1177 !path_has_mixer(codec, spec->speaker_paths[0], ctl_type)) in get_line_out_pfx()
1188 bool hp_lo_shared = !path_has_mixer(codec, spec->hp_paths[0], ctl_type); in get_line_out_pfx()
1189 bool spk_lo_shared = !path_has_mixer(codec, spec->speaker_paths[0], ctl_type); in get_line_out_pfx()
1246 static int assign_out_path_ctls(struct hda_codec *codec, struct nid_path *path) in assign_out_path_ctls() argument
1248 struct hda_gen_spec *spec = codec->spec; in assign_out_path_ctls()
1260 nid = look_for_out_vol_nid(codec, path); in assign_out_path_ctls()
1265 if (is_ctl_used(codec, val, NID_PATH_VOL_CTL)) in assign_out_path_ctls()
1271 nid = look_for_out_mute_nid(codec, path); in assign_out_path_ctls()
1273 unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); in assign_out_path_ctls()
1275 nid_has_mute(codec, nid, HDA_OUTPUT)) in assign_out_path_ctls()
1279 if (is_ctl_used(codec, val, NID_PATH_MUTE_CTL)) in assign_out_path_ctls()
1309 static hda_nid_t get_primary_out(struct hda_codec *codec, int idx) in get_primary_out() argument
1311 struct hda_gen_spec *spec = codec->spec; in get_primary_out()
1323 static inline hda_nid_t try_dac(struct hda_codec *codec, in try_dac() argument
1326 return is_reachable_path(codec, dac, pin) ? dac : 0; in try_dac()
1330 static int try_assign_dacs(struct hda_codec *codec, int num_outs, in try_assign_dacs() argument
1335 struct hda_gen_spec *spec = codec->spec; in try_assign_dacs()
1347 path = snd_hda_get_path_from_idx(codec, path_idx[i]); in try_assign_dacs()
1349 badness += assign_out_path_ctls(codec, path); in try_assign_dacs()
1353 dacs[i] = get_preferred_dac(codec, pin); in try_assign_dacs()
1355 if (is_dac_already_used(codec, dacs[i])) in try_assign_dacs()
1360 dacs[i] = look_for_dac(codec, pin, false); in try_assign_dacs()
1364 if (is_reachable_path(codec, dacs[j], pin)) { in try_assign_dacs()
1367 invalidate_nid_path(codec, path_idx[j]); in try_assign_dacs()
1376 dac = try_dac(codec, get_primary_out(codec, i), pin); in try_assign_dacs()
1378 dac = try_dac(codec, dacs[0], pin); in try_assign_dacs()
1380 dac = try_dac(codec, get_primary_out(codec, i), pin); in try_assign_dacs()
1388 } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { in try_assign_dacs()
1398 path = snd_hda_add_new_path(codec, dac, pin, -spec->mixer_nid); in try_assign_dacs()
1401 path = snd_hda_add_new_path(codec, dac, pin, 0); in try_assign_dacs()
1409 path_idx[i] = snd_hda_get_path_idx(codec, path); in try_assign_dacs()
1410 badness += assign_out_path_ctls(codec, path); in try_assign_dacs()
1418 static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) in get_dac_if_single() argument
1420 struct hda_gen_spec *spec = codec->spec; in get_dac_if_single()
1426 if (!nid || is_dac_already_used(codec, nid)) in get_dac_if_single()
1428 if (is_reachable_path(codec, nid, pin)) { in get_dac_if_single()
1438 static bool can_be_multiio_pin(struct hda_codec *codec, in can_be_multiio_pin() argument
1443 defcfg = snd_hda_codec_get_pincfg(codec, nid); in can_be_multiio_pin()
1448 caps = snd_hda_query_pin_caps(codec, nid); in can_be_multiio_pin()
1455 static int count_multiio_pins(struct hda_codec *codec, hda_nid_t reference_pin) in count_multiio_pins() argument
1457 struct hda_gen_spec *spec = codec->spec; in count_multiio_pins()
1459 unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); in count_multiio_pins()
1468 if (can_be_multiio_pin(codec, location, in count_multiio_pins()
1484 static int fill_multi_ios(struct hda_codec *codec, in fill_multi_ios() argument
1488 struct hda_gen_spec *spec = codec->spec; in fill_multi_ios()
1491 unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); in fill_multi_ios()
1500 num_pins = count_multiio_pins(codec, reference_pin); in fill_multi_ios()
1511 if (!can_be_multiio_pin(codec, location, nid)) in fill_multi_ios()
1521 dac = get_dac_if_single(codec, nid); in fill_multi_ios()
1523 dac = look_for_dac(codec, nid, false); in fill_multi_ios()
1528 path = snd_hda_add_new_path(codec, dac, nid, in fill_multi_ios()
1538 snd_hda_get_path_idx(codec, path); in fill_multi_ios()
1562 path = snd_hda_get_path_from_idx(codec, spec->out_paths[cfg->line_outs + i]); in fill_multi_ios()
1563 badness += assign_out_path_ctls(codec, path); in fill_multi_ios()
1570 static bool map_singles(struct hda_codec *codec, int outs, in map_singles() argument
1573 struct hda_gen_spec *spec = codec->spec; in map_singles()
1581 dac = get_dac_if_single(codec, pins[i]); in map_singles()
1584 path = snd_hda_add_new_path(codec, dac, pins[i], in map_singles()
1587 path = snd_hda_add_new_path(codec, dac, pins[i], 0); in map_singles()
1593 path_idx[i] = snd_hda_get_path_idx(codec, path); in map_singles()
1606 static int check_aamix_out_path(struct hda_codec *codec, int path_idx) in check_aamix_out_path() argument
1608 struct hda_gen_spec *spec = codec->spec; in check_aamix_out_path()
1612 path = snd_hda_get_path_from_idx(codec, path_idx); in check_aamix_out_path()
1619 path = snd_hda_add_new_path(codec, dac, pin, spec->mixer_nid); in check_aamix_out_path()
1630 path = snd_hda_add_new_path(codec, dac, pin, in check_aamix_out_path()
1638 return snd_hda_get_path_idx(codec, path); in check_aamix_out_path()
1642 static bool indep_hp_possible(struct hda_codec *codec) in indep_hp_possible() argument
1644 struct hda_gen_spec *spec = codec->spec; in indep_hp_possible()
1653 path = snd_hda_get_path_from_idx(codec, idx); in indep_hp_possible()
1665 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); in indep_hp_possible()
1670 path = snd_hda_get_path_from_idx(codec, spec->speaker_paths[i]); in indep_hp_possible()
1681 static void refill_shared_dacs(struct hda_codec *codec, int num_outs, in refill_shared_dacs() argument
1690 path = snd_hda_get_path_from_idx(codec, path_idx[i]); in refill_shared_dacs()
1698 static int fill_and_eval_dacs(struct hda_codec *codec, in fill_and_eval_dacs() argument
1702 struct hda_gen_spec *spec = codec->spec; in fill_and_eval_dacs()
1731 mapped = map_singles(codec, cfg->line_outs, in fill_and_eval_dacs()
1735 mapped |= map_singles(codec, cfg->hp_outs, in fill_and_eval_dacs()
1739 mapped |= map_singles(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1746 err = fill_multi_ios(codec, cfg->line_out_pins[0], true); in fill_and_eval_dacs()
1753 badness += try_assign_dacs(codec, cfg->line_outs, cfg->line_out_pins, in fill_and_eval_dacs()
1760 err = fill_multi_ios(codec, cfg->line_out_pins[0], false); in fill_and_eval_dacs()
1767 err = try_assign_dacs(codec, cfg->hp_outs, cfg->hp_pins, in fill_and_eval_dacs()
1776 err = try_assign_dacs(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1787 err = fill_multi_ios(codec, cfg->line_out_pins[0], false); in fill_and_eval_dacs()
1795 check_aamix_out_path(codec, spec->out_paths[0]); in fill_and_eval_dacs()
1798 check_aamix_out_path(codec, spec->hp_paths[0]); in fill_and_eval_dacs()
1801 check_aamix_out_path(codec, spec->speaker_paths[0]); in fill_and_eval_dacs()
1806 if (count_multiio_pins(codec, cfg->hp_pins[0]) >= 2) in fill_and_eval_dacs()
1834 if (spec->indep_hp && !indep_hp_possible(codec)) in fill_and_eval_dacs()
1839 refill_shared_dacs(codec, cfg->hp_outs, in fill_and_eval_dacs()
1843 refill_shared_dacs(codec, cfg->speaker_outs, in fill_and_eval_dacs()
1854 codec_dbg(codec, fmt, ##__VA_ARGS__)
1857 do { if (0) codec_dbg(codec, fmt, ##__VA_ARGS__); } while (0)
1861 static inline void print_nid_path_idx(struct hda_codec *codec, in print_nid_path_idx() argument
1866 path = snd_hda_get_path_from_idx(codec, idx); in print_nid_path_idx()
1868 print_nid_path(codec, pfx, path); in print_nid_path_idx()
1871 static void debug_show_configs(struct hda_codec *codec, in debug_show_configs() argument
1874 struct hda_gen_spec *spec = codec->spec; in debug_show_configs()
1887 print_nid_path_idx(codec, " out", spec->out_paths[i]); in debug_show_configs()
1894 print_nid_path_idx(codec, " mio", in debug_show_configs()
1905 print_nid_path_idx(codec, " hp ", spec->hp_paths[i]); in debug_show_configs()
1915 print_nid_path_idx(codec, " spk", spec->speaker_paths[i]); in debug_show_configs()
1917 print_nid_path_idx(codec, " mix", spec->aamix_out_paths[i]); in debug_show_configs()
1920 #define debug_show_configs(codec, cfg) /* NOP */ argument
1924 static void fill_all_dac_nids(struct hda_codec *codec) in fill_all_dac_nids() argument
1926 struct hda_gen_spec *spec = codec->spec; in fill_all_dac_nids()
1931 for_each_hda_codec_node(nid, codec) { in fill_all_dac_nids()
1932 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) in fill_all_dac_nids()
1935 codec_err(codec, "Too many DACs!\n"); in fill_all_dac_nids()
1942 static int parse_output_paths(struct hda_codec *codec) in parse_output_paths() argument
1944 struct hda_gen_spec *spec = codec->spec; in parse_output_paths()
1960 badness = fill_and_eval_dacs(codec, fill_hardwired, in parse_output_paths()
1969 debug_show_configs(codec, cfg); in parse_output_paths()
2021 fill_and_eval_dacs(codec, best_wired, best_mio); in parse_output_paths()
2025 debug_show_configs(codec, cfg); in parse_output_paths()
2029 path = snd_hda_get_path_from_idx(codec, spec->out_paths[0]); in parse_output_paths()
2031 spec->vmaster_nid = look_for_out_vol_nid(codec, path); in parse_output_paths()
2033 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, in parse_output_paths()
2045 set_pin_targets(codec, cfg->line_outs, cfg->line_out_pins, val); in parse_output_paths()
2047 set_pin_targets(codec, cfg->hp_outs, cfg->hp_pins, PIN_HP); in parse_output_paths()
2050 set_pin_targets(codec, cfg->speaker_outs, in parse_output_paths()
2055 if (spec->indep_hp && !indep_hp_possible(codec)) in parse_output_paths()
2063 static int create_multi_out_ctls(struct hda_codec *codec, in create_multi_out_ctls() argument
2066 struct hda_gen_spec *spec = codec->spec; in create_multi_out_ctls()
2078 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); in create_multi_out_ctls()
2082 name = get_line_out_pfx(codec, i, &index, NID_PATH_VOL_CTL); in create_multi_out_ctls()
2085 err = add_vol_ctl(codec, "Center", 0, 1, path); in create_multi_out_ctls()
2088 err = add_vol_ctl(codec, "LFE", 0, 2, path); in create_multi_out_ctls()
2092 err = add_stereo_vol(codec, name, index, path); in create_multi_out_ctls()
2097 name = get_line_out_pfx(codec, i, &index, NID_PATH_MUTE_CTL); in create_multi_out_ctls()
2099 err = add_sw_ctl(codec, "Center", 0, 1, path); in create_multi_out_ctls()
2102 err = add_sw_ctl(codec, "LFE", 0, 2, path); in create_multi_out_ctls()
2106 err = add_stereo_sw(codec, name, index, path); in create_multi_out_ctls()
2114 static int create_extra_out(struct hda_codec *codec, int path_idx, in create_extra_out() argument
2120 path = snd_hda_get_path_from_idx(codec, path_idx); in create_extra_out()
2123 err = add_stereo_vol(codec, pfx, cidx, path); in create_extra_out()
2126 err = add_stereo_sw(codec, pfx, cidx, path); in create_extra_out()
2133 static int create_extra_outs(struct hda_codec *codec, int num_pins, in create_extra_outs() argument
2153 err = create_extra_out(codec, paths[i], name, idx); in create_extra_outs()
2160 static int create_hp_out_ctls(struct hda_codec *codec) in create_hp_out_ctls() argument
2162 struct hda_gen_spec *spec = codec->spec; in create_hp_out_ctls()
2163 return create_extra_outs(codec, spec->autocfg.hp_outs, in create_hp_out_ctls()
2168 static int create_speaker_out_ctls(struct hda_codec *codec) in create_speaker_out_ctls() argument
2170 struct hda_gen_spec *spec = codec->spec; in create_speaker_out_ctls()
2171 return create_extra_outs(codec, spec->autocfg.speaker_outs, in create_speaker_out_ctls()
2180 static void call_hp_automute(struct hda_codec *codec,
2191 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in indep_hp_get() local
2192 struct hda_gen_spec *spec = codec->spec; in indep_hp_get()
2197 static void update_aamix_paths(struct hda_codec *codec, bool do_mix,
2204 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in indep_hp_put() local
2205 struct hda_gen_spec *spec = codec->spec; in indep_hp_put()
2225 update_aamix_paths(codec, spec->aamix_mode, in indep_hp_put()
2230 update_aamix_paths(codec, spec->aamix_mode, in indep_hp_put()
2242 call_hp_automute(codec, NULL); in indep_hp_put()
2259 static int create_indep_hp_ctls(struct hda_codec *codec) in create_indep_hp_ctls() argument
2261 struct hda_gen_spec *spec = codec->spec; in create_indep_hp_ctls()
2289 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ch_mode_info() local
2290 struct hda_gen_spec *spec = codec->spec; in ch_mode_info()
2306 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ch_mode_get() local
2307 struct hda_gen_spec *spec = codec->spec; in ch_mode_get()
2314 get_multiio_path(struct hda_codec *codec, int idx) in get_multiio_path() argument
2316 struct hda_gen_spec *spec = codec->spec; in get_multiio_path()
2317 return snd_hda_get_path_from_idx(codec, in get_multiio_path()
2321 static void update_automute_all(struct hda_codec *codec);
2331 static int set_multi_io(struct hda_codec *codec, int idx, bool output) in set_multi_io() argument
2333 struct hda_gen_spec *spec = codec->spec; in set_multi_io()
2337 path = get_multiio_path(codec, idx); in set_multi_io()
2345 set_pin_target(codec, nid, PIN_OUT, true); in set_multi_io()
2346 snd_hda_activate_path(codec, path, true, aamix_default(spec)); in set_multi_io()
2347 set_pin_eapd(codec, nid, true); in set_multi_io()
2349 set_pin_eapd(codec, nid, false); in set_multi_io()
2350 snd_hda_activate_path(codec, path, false, aamix_default(spec)); in set_multi_io()
2351 set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true); in set_multi_io()
2352 path_power_down_sync(codec, path); in set_multi_io()
2356 update_automute_all(codec); in set_multi_io()
2364 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in ch_mode_put() local
2365 struct hda_gen_spec *spec = codec->spec; in ch_mode_put()
2375 set_multi_io(codec, i, i < ch); in ch_mode_put()
2391 static int create_multi_channel_mode(struct hda_codec *codec) in create_multi_channel_mode() argument
2393 struct hda_gen_spec *spec = codec->spec; in create_multi_channel_mode()
2411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in loopback_mixing_get() local
2412 struct hda_gen_spec *spec = codec->spec; in loopback_mixing_get()
2417 static void update_aamix_paths(struct hda_codec *codec, bool do_mix, in update_aamix_paths() argument
2421 struct hda_gen_spec *spec = codec->spec; in update_aamix_paths()
2424 nomix_path = snd_hda_get_path_from_idx(codec, nomix_path_idx); in update_aamix_paths()
2425 mix_path = snd_hda_get_path_from_idx(codec, mix_path_idx); in update_aamix_paths()
2437 snd_hda_activate_path(codec, nomix_path, false, true); in update_aamix_paths()
2438 snd_hda_activate_path(codec, mix_path, true, true); in update_aamix_paths()
2439 path_power_down_sync(codec, nomix_path); in update_aamix_paths()
2441 snd_hda_activate_path(codec, mix_path, false, false); in update_aamix_paths()
2442 snd_hda_activate_path(codec, nomix_path, true, false); in update_aamix_paths()
2443 path_power_down_sync(codec, mix_path); in update_aamix_paths()
2448 static void update_output_paths(struct hda_codec *codec, int num_outs, in update_output_paths() argument
2451 struct hda_gen_spec *spec = codec->spec; in update_output_paths()
2456 path = snd_hda_get_path_from_idx(codec, paths[i]); in update_output_paths()
2458 snd_hda_activate_path(codec, path, path->active, in update_output_paths()
2466 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in loopback_mixing_put() local
2467 struct hda_gen_spec *spec = codec->spec; in loopback_mixing_put()
2475 update_aamix_paths(codec, val, spec->out_paths[0], in loopback_mixing_put()
2478 update_aamix_paths(codec, val, spec->hp_paths[0], in loopback_mixing_put()
2481 update_aamix_paths(codec, val, spec->speaker_paths[0], in loopback_mixing_put()
2485 update_output_paths(codec, cfg->line_outs, spec->out_paths); in loopback_mixing_put()
2487 update_output_paths(codec, cfg->hp_outs, spec->hp_paths); in loopback_mixing_put()
2489 update_output_paths(codec, cfg->speaker_outs, in loopback_mixing_put()
2503 static int create_loopback_mixing_ctl(struct hda_codec *codec) in create_loopback_mixing_ctl() argument
2505 struct hda_gen_spec *spec = codec->spec; in create_loopback_mixing_ctl()
2523 static void call_update_outputs(struct hda_codec *codec);
2526 static void update_hp_mic(struct hda_codec *codec, int adc_mux, bool force) in update_hp_mic() argument
2528 struct hda_gen_spec *spec = codec->spec; in update_hp_mic()
2537 val = snd_hda_codec_get_pin_target(codec, pin); in update_hp_mic()
2547 val = snd_hda_get_default_vref(codec, pin); in update_hp_mic()
2553 unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); in update_hp_mic()
2555 snd_hda_set_pin_ctl_cache(codec, vref_pin, in update_hp_mic()
2564 set_pin_target(codec, pin, val, true); in update_hp_mic()
2565 call_hp_automute(codec, NULL); in update_hp_mic()
2570 static int create_hp_mic(struct hda_codec *codec) in create_hp_mic() argument
2572 struct hda_gen_spec *spec = codec->spec; in create_hp_mic()
2586 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); in create_hp_mic()
2604 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) in create_hp_mic()
2615 codec_dbg(codec, "Enable shared I/O jack on NID 0x%x\n", nid); in create_hp_mic()
2623 static int create_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t pin);
2638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in out_jack_mode_get() local
2640 if (snd_hda_codec_get_pin_target(codec, nid) == PIN_HP) in out_jack_mode_get()
2650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in out_jack_mode_put() local
2655 if (snd_hda_codec_get_pin_target(codec, nid) == val) in out_jack_mode_put()
2657 snd_hda_set_pin_ctl_cache(codec, nid, val); in out_jack_mode_put()
2668 static bool find_kctl_name(struct hda_codec *codec, const char *name, int idx) in find_kctl_name() argument
2670 struct hda_gen_spec *spec = codec->spec; in find_kctl_name()
2681 static void get_jack_mode_name(struct hda_codec *codec, hda_nid_t pin, in get_jack_mode_name() argument
2684 struct hda_gen_spec *spec = codec->spec; in get_jack_mode_name()
2687 snd_hda_get_pin_label(codec, pin, &spec->autocfg, name, name_len, &idx); in get_jack_mode_name()
2690 for (; find_kctl_name(codec, name, idx); idx++) in get_jack_mode_name()
2694 static int get_out_jack_num_items(struct hda_codec *codec, hda_nid_t pin) in get_out_jack_num_items() argument
2696 struct hda_gen_spec *spec = codec->spec; in get_out_jack_num_items()
2698 unsigned int pincap = snd_hda_query_pin_caps(codec, pin); in get_out_jack_num_items()
2705 static int create_out_jack_modes(struct hda_codec *codec, int num_pins, in create_out_jack_modes() argument
2708 struct hda_gen_spec *spec = codec->spec; in create_out_jack_modes()
2715 if (get_out_jack_num_items(codec, pin) > 1) { in create_out_jack_modes()
2718 get_jack_mode_name(codec, pin, name, sizeof(name)); in create_out_jack_modes()
2742 static unsigned int get_vref_caps(struct hda_codec *codec, hda_nid_t pin) in get_vref_caps() argument
2746 pincap = snd_hda_query_pin_caps(codec, pin); in get_vref_caps()
2785 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in in_jack_mode_info() local
2787 unsigned int vref_caps = get_vref_caps(codec, nid); in in_jack_mode_info()
2800 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in in_jack_mode_get() local
2802 unsigned int vref_caps = get_vref_caps(codec, nid); in in_jack_mode_get()
2805 idx = snd_hda_codec_get_pin_target(codec, nid) & AC_PINCTL_VREFEN; in in_jack_mode_get()
2813 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in in_jack_mode_put() local
2815 unsigned int vref_caps = get_vref_caps(codec, nid); in in_jack_mode_put()
2818 val = snd_hda_codec_get_pin_target(codec, nid); in in_jack_mode_put()
2825 snd_hda_set_pin_ctl_cache(codec, nid, val); in in_jack_mode_put()
2836 static int get_in_jack_num_items(struct hda_codec *codec, hda_nid_t pin) in get_in_jack_num_items() argument
2838 struct hda_gen_spec *spec = codec->spec; in get_in_jack_num_items()
2841 nitems = hweight32(get_vref_caps(codec, pin)); in get_in_jack_num_items()
2845 static int create_in_jack_mode(struct hda_codec *codec, hda_nid_t pin) in create_in_jack_mode() argument
2847 struct hda_gen_spec *spec = codec->spec; in create_in_jack_mode()
2856 defcfg = snd_hda_codec_get_pincfg(codec, pin); in create_in_jack_mode()
2861 if (get_in_jack_num_items(codec, pin) <= 1) in create_in_jack_mode()
2864 get_jack_mode_name(codec, pin, name, sizeof(name)); in create_in_jack_mode()
2878 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hp_mic_jack_mode_info() local
2880 int out_jacks = get_out_jack_num_items(codec, nid); in hp_mic_jack_mode_info()
2881 int in_jacks = get_in_jack_num_items(codec, nid); in hp_mic_jack_mode_info()
2899 unsigned int vref_caps = get_vref_caps(codec, nid); in hp_mic_jack_mode_info()
2909 static int get_cur_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t nid) in get_cur_hp_mic_jack_mode() argument
2911 int out_jacks = get_out_jack_num_items(codec, nid); in get_cur_hp_mic_jack_mode()
2912 int in_jacks = get_in_jack_num_items(codec, nid); in get_cur_hp_mic_jack_mode()
2913 unsigned int val = snd_hda_codec_get_pin_target(codec, nid); in get_cur_hp_mic_jack_mode()
2922 unsigned int vref_caps = get_vref_caps(codec, nid); in get_cur_hp_mic_jack_mode()
2933 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hp_mic_jack_mode_get() local
2936 get_cur_hp_mic_jack_mode(codec, nid); in hp_mic_jack_mode_get()
2943 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hp_mic_jack_mode_put() local
2945 int out_jacks = get_out_jack_num_items(codec, nid); in hp_mic_jack_mode_put()
2946 int in_jacks = get_in_jack_num_items(codec, nid); in hp_mic_jack_mode_put()
2949 oldval = get_cur_hp_mic_jack_mode(codec, nid); in hp_mic_jack_mode_put()
2962 unsigned int vref_caps = get_vref_caps(codec, nid); in hp_mic_jack_mode_put()
2963 val = snd_hda_codec_get_pin_target(codec, nid); in hp_mic_jack_mode_put()
2967 val = snd_hda_get_default_vref(codec, nid) | PIN_IN; in hp_mic_jack_mode_put()
2969 snd_hda_set_pin_ctl_cache(codec, nid, val); in hp_mic_jack_mode_put()
2970 call_hp_automute(codec, NULL); in hp_mic_jack_mode_put()
2982 static int create_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t pin) in create_hp_mic_jack_mode() argument
2984 struct hda_gen_spec *spec = codec->spec; in create_hp_mic_jack_mode()
3018 static bool look_for_mix_leaf_ctls(struct hda_codec *codec, hda_nid_t mix_nid, in look_for_mix_leaf_ctls() argument
3026 idx = snd_hda_get_conn_index(codec, mix_nid, pin, true); in look_for_mix_leaf_ctls()
3031 if (nid_has_volume(codec, mix_nid, HDA_INPUT)) in look_for_mix_leaf_ctls()
3033 if (nid_has_mute(codec, mix_nid, HDA_INPUT)) in look_for_mix_leaf_ctls()
3039 num_conns = snd_hda_get_conn_list(codec, mix_nid, &list); in look_for_mix_leaf_ctls()
3043 if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT) && in look_for_mix_leaf_ctls()
3044 !is_ctl_associated(codec, nid, HDA_OUTPUT, 0, NID_PATH_VOL_CTL)) in look_for_mix_leaf_ctls()
3046 if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT) && in look_for_mix_leaf_ctls()
3047 !is_ctl_associated(codec, nid, HDA_OUTPUT, 0, NID_PATH_MUTE_CTL)) in look_for_mix_leaf_ctls()
3054 static int new_analog_input(struct hda_codec *codec, int input_idx, in new_analog_input() argument
3058 struct hda_gen_spec *spec = codec->spec; in new_analog_input()
3063 if (!look_for_mix_leaf_ctls(codec, mix_nid, pin, &mix_val, &mute_val)) in new_analog_input()
3066 path = snd_hda_add_new_path(codec, pin, mix_nid, 0); in new_analog_input()
3069 print_nid_path(codec, "loopback", path); in new_analog_input()
3070 spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path); in new_analog_input()
3095 path = snd_hda_add_new_path(codec, spec->mixer_nid, in new_analog_input()
3098 print_nid_path(codec, "loopback-merge", path); in new_analog_input()
3103 snd_hda_get_path_idx(codec, path); in new_analog_input()
3110 static int is_input_pin(struct hda_codec *codec, hda_nid_t nid) in is_input_pin() argument
3112 unsigned int pincap = snd_hda_query_pin_caps(codec, nid); in is_input_pin()
3117 static int fill_adc_nids(struct hda_codec *codec) in fill_adc_nids() argument
3119 struct hda_gen_spec *spec = codec->spec; in fill_adc_nids()
3125 for_each_hda_codec_node(nid, codec) { in fill_adc_nids()
3126 unsigned int caps = get_wcaps(codec, nid); in fill_adc_nids()
3147 static int check_dyn_adc_switch(struct hda_codec *codec) in check_dyn_adc_switch() argument
3149 struct hda_gen_spec *spec = codec->spec; in check_dyn_adc_switch()
3178 codec_dbg(codec, "enabling ADC switching\n"); in check_dyn_adc_switch()
3189 invalidate_nid_path(codec, in check_dyn_adc_switch()
3202 codec_dbg(codec, "reducing to a single ADC\n"); in check_dyn_adc_switch()
3214 static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin, in parse_capture_source() argument
3218 struct hda_gen_spec *spec = codec->spec; in parse_capture_source()
3228 if (!is_reachable_path(codec, pin, adc)) in parse_capture_source()
3230 path = snd_hda_add_new_path(codec, pin, adc, anchor); in parse_capture_source()
3233 print_nid_path(codec, "input", path); in parse_capture_source()
3235 snd_hda_get_path_idx(codec, path); in parse_capture_source()
3241 snd_hda_add_imux_item(codec, imux, label, cfg_idx, NULL); in parse_capture_source()
3256 static int fill_input_pin_labels(struct hda_codec *codec) in fill_input_pin_labels() argument
3258 struct hda_gen_spec *spec = codec->spec; in fill_input_pin_labels()
3267 if (!is_input_pin(codec, pin)) in fill_input_pin_labels()
3270 label = hda_get_autocfg_input_label(codec, cfg, i); in fill_input_pin_labels()
3289 static int create_input_ctls(struct hda_codec *codec) in create_input_ctls() argument
3291 struct hda_gen_spec *spec = codec->spec; in create_input_ctls()
3298 num_adcs = fill_adc_nids(codec); in create_input_ctls()
3302 err = fill_input_pin_labels(codec); in create_input_ctls()
3310 if (!is_input_pin(codec, pin)) in create_input_ctls()
3315 val |= snd_hda_get_default_vref(codec, pin); in create_input_ctls()
3317 !snd_hda_codec_get_pin_target(codec, pin)) in create_input_ctls()
3318 set_pin_target(codec, pin, val, false); in create_input_ctls()
3321 if (is_reachable_path(codec, pin, mixer)) { in create_input_ctls()
3322 err = new_analog_input(codec, i, pin, in create_input_ctls()
3331 err = parse_capture_source(codec, pin, i, num_adcs, in create_input_ctls()
3337 err = create_in_jack_mode(codec, pin); in create_input_ctls()
3345 err = parse_capture_source(codec, mixer, CFG_IDX_MIX, num_adcs, in create_input_ctls()
3362 static struct nid_path *get_input_path(struct hda_codec *codec, int adc_idx, int imux_idx) in get_input_path() argument
3364 struct hda_gen_spec *spec = codec->spec; in get_input_path()
3375 return snd_hda_get_path_from_idx(codec, spec->input_paths[imux_idx][adc_idx]); in get_input_path()
3378 static int mux_select(struct hda_codec *codec, unsigned int adc_idx,
3384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in mux_enum_info() local
3385 struct hda_gen_spec *spec = codec->spec; in mux_enum_info()
3392 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in mux_enum_get() local
3393 struct hda_gen_spec *spec = codec->spec; in mux_enum_get()
3404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in mux_enum_put() local
3406 return mux_select(codec, adc_idx, in mux_enum_put()
3430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cap_put_caller() local
3431 struct hda_gen_spec *spec = codec->spec; in cap_put_caller()
3438 mutex_lock(&codec->control_mutex); in cap_put_caller()
3440 path = get_input_path(codec, adc_idx, i); in cap_put_caller()
3448 mutex_unlock(&codec->control_mutex); in cap_put_caller()
3450 spec->cap_sync_hook(codec, kcontrol, ucontrol); in cap_put_caller()
3499 static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path) in parse_capvol_in_path() argument
3511 if (nid_has_volume(codec, nid, HDA_OUTPUT)) in parse_capvol_in_path()
3514 else if (nid_has_volume(codec, nid, HDA_INPUT)) { in parse_capvol_in_path()
3516 if (!depth && codec->single_adc_amp) in parse_capvol_in_path()
3523 if (nid_has_mute(codec, nid, HDA_OUTPUT)) in parse_capvol_in_path()
3526 else if (nid_has_mute(codec, nid, HDA_INPUT)) { in parse_capvol_in_path()
3528 if (!depth && codec->single_adc_amp) in parse_capvol_in_path()
3538 static bool is_inv_dmic_pin(struct hda_codec *codec, hda_nid_t nid) in is_inv_dmic_pin() argument
3540 struct hda_gen_spec *spec = codec->spec; in is_inv_dmic_pin()
3552 val = snd_hda_codec_get_pincfg(codec, nid); in is_inv_dmic_pin()
3562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cap_single_sw_put() local
3563 struct hda_gen_spec *spec = codec->spec; in cap_single_sw_put()
3571 spec->cap_sync_hook(codec, kcontrol, ucontrol); in cap_single_sw_put()
3576 static int add_single_cap_ctl(struct hda_codec *codec, const char *label, in add_single_cap_ctl() argument
3580 struct hda_gen_spec *spec = codec->spec; in add_single_cap_ctl()
3622 static int create_single_cap_vol_ctl(struct hda_codec *codec, int idx, in create_single_cap_vol_ctl() argument
3627 err = add_single_cap_ctl(codec, NULL, idx, false, vol_ctl, inv_dmic); in create_single_cap_vol_ctl()
3630 err = add_single_cap_ctl(codec, NULL, idx, true, sw_ctl, inv_dmic); in create_single_cap_vol_ctl()
3637 static int create_bind_cap_vol_ctl(struct hda_codec *codec, int idx, in create_bind_cap_vol_ctl() argument
3640 struct hda_gen_spec *spec = codec->spec; in create_bind_cap_vol_ctl()
3663 static unsigned int get_first_cap_ctl(struct hda_codec *codec, int idx, int type) in get_first_cap_ctl() argument
3669 path = get_input_path(codec, 0, idx); in get_first_cap_ctl()
3676 path = get_input_path(codec, 0, i); in get_first_cap_ctl()
3684 static int create_multi_cap_vol_ctl(struct hda_codec *codec) in create_multi_cap_vol_ctl() argument
3686 struct hda_gen_spec *spec = codec->spec; in create_multi_cap_vol_ctl()
3697 inv_dmic = is_inv_dmic_pin(codec, spec->imux_pins[i]); in create_multi_cap_vol_ctl()
3700 err = add_single_cap_ctl(codec, in create_multi_cap_vol_ctl()
3704 get_first_cap_ctl(codec, i, type), in create_multi_cap_vol_ctl()
3713 static int create_capture_mixers(struct hda_codec *codec) in create_capture_mixers() argument
3715 struct hda_gen_spec *spec = codec->spec; in create_capture_mixers()
3743 path = get_input_path(codec, n, i); in create_capture_mixers()
3746 parse_capvol_in_path(codec, path); in create_capture_mixers()
3751 if (!same_amp_caps(codec, vol, in create_capture_mixers()
3759 if (!same_amp_caps(codec, sw, in create_capture_mixers()
3763 if (is_inv_dmic_pin(codec, spec->imux_pins[i])) in create_capture_mixers()
3768 err = create_single_cap_vol_ctl(codec, n, vol, sw, in create_capture_mixers()
3771 err = create_bind_cap_vol_ctl(codec, n, vol, sw); in create_capture_mixers()
3773 err = create_multi_cap_vol_ctl(codec); in create_capture_mixers()
3786 static bool check_boost_vol(struct hda_codec *codec, hda_nid_t nid, in check_boost_vol() argument
3791 if (!nid_has_volume(codec, nid, dir) || in check_boost_vol()
3792 is_ctl_associated(codec, nid, dir, idx, NID_PATH_VOL_CTL) || in check_boost_vol()
3793 is_ctl_associated(codec, nid, dir, idx, NID_PATH_BOOST_CTL)) in check_boost_vol()
3796 step = (query_amp_caps(codec, nid, dir) & AC_AMPCAP_STEP_SIZE) in check_boost_vol()
3804 static unsigned int look_for_boost_amp(struct hda_codec *codec, in look_for_boost_amp() argument
3815 if (depth && check_boost_vol(codec, nid, HDA_OUTPUT, 0)) { in look_for_boost_amp()
3818 } else if (check_boost_vol(codec, nid, HDA_INPUT, in look_for_boost_amp()
3829 static int parse_mic_boost(struct hda_codec *codec) in parse_mic_boost() argument
3831 struct hda_gen_spec *spec = codec->spec; in parse_mic_boost()
3853 path = get_input_path(codec, 0, i); in parse_mic_boost()
3857 val = look_for_boost_amp(codec, path); in parse_mic_boost()
3876 static void parse_digital(struct hda_codec *codec) in parse_digital() argument
3878 struct hda_gen_spec *spec = codec->spec; in parse_digital()
3887 dig_nid = look_for_dac(codec, pin, true); in parse_digital()
3890 path = snd_hda_add_new_path(codec, dig_nid, pin, 0); in parse_digital()
3893 print_nid_path(codec, "digout", path); in parse_digital()
3896 spec->digout_paths[i] = snd_hda_get_path_idx(codec, path); in parse_digital()
3897 set_pin_target(codec, pin, PIN_OUT, false); in parse_digital()
3912 for_each_hda_codec_node(dig_nid, codec) { in parse_digital()
3913 unsigned int wcaps = get_wcaps(codec, dig_nid); in parse_digital()
3918 path = snd_hda_add_new_path(codec, pin, dig_nid, 0); in parse_digital()
3920 print_nid_path(codec, "digin", path); in parse_digital()
3924 spec->digin_path = snd_hda_get_path_idx(codec, path); in parse_digital()
3925 set_pin_target(codec, pin, PIN_IN, false); in parse_digital()
3937 static bool dyn_adc_pcm_resetup(struct hda_codec *codec, int cur);
3940 static int mux_select(struct hda_codec *codec, unsigned int adc_idx, in mux_select() argument
3943 struct hda_gen_spec *spec = codec->spec; in mux_select()
3956 old_path = get_input_path(codec, adc_idx, spec->cur_mux[adc_idx]); in mux_select()
3960 snd_hda_activate_path(codec, old_path, false, false); in mux_select()
3965 update_hp_mic(codec, adc_idx, false); in mux_select()
3968 dyn_adc_pcm_resetup(codec, idx); in mux_select()
3970 path = get_input_path(codec, adc_idx, idx); in mux_select()
3975 snd_hda_activate_path(codec, path, true, false); in mux_select()
3977 spec->cap_sync_hook(codec, NULL, NULL); in mux_select()
3978 path_power_down_sync(codec, old_path); in mux_select()
3987 static hda_nid_t set_path_power(struct hda_codec *codec, hda_nid_t nid, in set_path_power() argument
3990 struct hda_gen_spec *spec = codec->spec; in set_path_power()
4008 last = path_power_update(codec, path, true); in set_path_power()
4018 static bool detect_pin_state(struct hda_codec *codec, hda_nid_t pin) in detect_pin_state() argument
4020 if (!is_jack_detectable(codec, pin)) in detect_pin_state()
4022 return snd_hda_jack_detect_state(codec, pin) != HDA_JACK_NOT_PRESENT; in detect_pin_state()
4031 static hda_nid_t set_pin_power_jack(struct hda_codec *codec, hda_nid_t pin, in set_pin_power_jack() argument
4036 if (!codec->power_save_node) in set_pin_power_jack()
4039 on = detect_pin_state(codec, pin); in set_pin_power_jack()
4043 return set_path_power(codec, pin, on, -1); in set_pin_power_jack()
4046 static void pin_power_callback(struct hda_codec *codec, in pin_power_callback() argument
4051 sync_power_state_change(codec, in pin_power_callback()
4052 set_pin_power_jack(codec, jack->nid, on)); in pin_power_callback()
4056 static void pin_power_up_callback(struct hda_codec *codec, in pin_power_up_callback() argument
4059 pin_power_callback(codec, jack, true); in pin_power_up_callback()
4063 static void pin_power_down_callback(struct hda_codec *codec, in pin_power_down_callback() argument
4066 pin_power_callback(codec, jack, false); in pin_power_down_callback()
4070 static void add_pin_power_ctls(struct hda_codec *codec, int num_pins, in add_pin_power_ctls() argument
4078 if (is_jack_detectable(codec, pins[i])) in add_pin_power_ctls()
4079 snd_hda_jack_detect_enable_callback(codec, pins[i], cb); in add_pin_power_ctls()
4081 set_path_power(codec, pins[i], true, -1); in add_pin_power_ctls()
4088 static void add_all_pin_power_ctls(struct hda_codec *codec, bool on) in add_all_pin_power_ctls() argument
4090 struct hda_gen_spec *spec = codec->spec; in add_all_pin_power_ctls()
4094 if (!codec->power_save_node) in add_all_pin_power_ctls()
4096 add_pin_power_ctls(codec, cfg->line_outs, cfg->line_out_pins, on); in add_all_pin_power_ctls()
4098 add_pin_power_ctls(codec, cfg->hp_outs, cfg->hp_pins, on); in add_all_pin_power_ctls()
4100 add_pin_power_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, on); in add_all_pin_power_ctls()
4102 add_pin_power_ctls(codec, 1, &cfg->inputs[i].pin, on); in add_all_pin_power_ctls()
4106 static void sync_pin_power_ctls(struct hda_codec *codec, int num_pins, in sync_pin_power_ctls() argument
4112 if (is_jack_detectable(codec, pins[i])) in sync_pin_power_ctls()
4113 set_pin_power_jack(codec, pins[i], -1); in sync_pin_power_ctls()
4117 static void sync_all_pin_power_ctls(struct hda_codec *codec) in sync_all_pin_power_ctls() argument
4119 struct hda_gen_spec *spec = codec->spec; in sync_all_pin_power_ctls()
4123 if (!codec->power_save_node) in sync_all_pin_power_ctls()
4125 sync_pin_power_ctls(codec, cfg->line_outs, cfg->line_out_pins); in sync_all_pin_power_ctls()
4127 sync_pin_power_ctls(codec, cfg->hp_outs, cfg->hp_pins); in sync_all_pin_power_ctls()
4129 sync_pin_power_ctls(codec, cfg->speaker_outs, cfg->speaker_pins); in sync_all_pin_power_ctls()
4131 sync_pin_power_ctls(codec, 1, &cfg->inputs[i].pin); in sync_all_pin_power_ctls()
4135 static int add_fake_paths(struct hda_codec *codec, hda_nid_t nid, in add_fake_paths() argument
4138 struct hda_gen_spec *spec = codec->spec; in add_fake_paths()
4145 if (get_nid_path(codec, nid, pins[i], 0)) in add_fake_paths()
4160 static int add_fake_beep_paths(struct hda_codec *codec) in add_fake_beep_paths() argument
4162 struct hda_gen_spec *spec = codec->spec; in add_fake_beep_paths()
4167 if (!codec->power_save_node || !nid) in add_fake_beep_paths()
4169 err = add_fake_paths(codec, nid, cfg->line_outs, cfg->line_out_pins); in add_fake_beep_paths()
4173 err = add_fake_paths(codec, nid, cfg->hp_outs, cfg->hp_pins); in add_fake_beep_paths()
4178 err = add_fake_paths(codec, nid, cfg->speaker_outs, in add_fake_beep_paths()
4189 set_path_power(beep->codec, beep->nid, -1, on); in beep_power_hook()
4197 int snd_hda_gen_fix_pin_power(struct hda_codec *codec, hda_nid_t pin) in snd_hda_gen_fix_pin_power() argument
4199 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_fix_pin_power()
4220 static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) in detect_jacks() argument
4230 if (snd_hda_codec_get_pin_target(codec, nid) & AC_PINCTL_IN_EN) in detect_jacks()
4232 if (snd_hda_jack_detect_state(codec, nid) == HDA_JACK_PRESENT) in detect_jacks()
4239 static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, in do_automute() argument
4242 struct hda_gen_spec *spec = codec->spec; in do_automute()
4251 oldval = snd_hda_codec_get_pin_target(codec, nid); in do_automute()
4259 path = snd_hda_get_path_from_idx(codec, paths[i]); in do_automute()
4285 update_pin_ctl(codec, nid, val); in do_automute()
4288 set_pin_eapd(codec, nid, !mute); in do_automute()
4289 if (codec->power_save_node) { in do_automute()
4292 on = detect_pin_state(codec, nid); in do_automute()
4293 set_path_power(codec, nid, on, -1); in do_automute()
4304 void snd_hda_gen_update_outputs(struct hda_codec *codec) in snd_hda_gen_update_outputs() argument
4306 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_update_outputs()
4318 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), in snd_hda_gen_update_outputs()
4331 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), in snd_hda_gen_update_outputs()
4346 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), in snd_hda_gen_update_outputs()
4351 static void call_update_outputs(struct hda_codec *codec) in call_update_outputs() argument
4353 struct hda_gen_spec *spec = codec->spec; in call_update_outputs()
4355 spec->automute_hook(codec); in call_update_outputs()
4357 snd_hda_gen_update_outputs(codec); in call_update_outputs()
4360 if (spec->auto_mute_via_amp && !codec->bus->shutdown) in call_update_outputs()
4369 void snd_hda_gen_hp_automute(struct hda_codec *codec, in snd_hda_gen_hp_automute() argument
4372 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_hp_automute()
4382 spec->hp_jack_present = detect_jacks(codec, num_pins, pins); in snd_hda_gen_hp_automute()
4385 call_update_outputs(codec); in snd_hda_gen_hp_automute()
4394 void snd_hda_gen_line_automute(struct hda_codec *codec, in snd_hda_gen_line_automute() argument
4397 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_line_automute()
4406 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), in snd_hda_gen_line_automute()
4410 call_update_outputs(codec); in snd_hda_gen_line_automute()
4419 void snd_hda_gen_mic_autoswitch(struct hda_codec *codec, in snd_hda_gen_mic_autoswitch() argument
4422 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_mic_autoswitch()
4431 if (snd_hda_codec_get_pin_target(codec, pin) & AC_PINCTL_OUT_EN) in snd_hda_gen_mic_autoswitch()
4433 if (snd_hda_jack_detect_state(codec, pin) == HDA_JACK_PRESENT) { in snd_hda_gen_mic_autoswitch()
4434 mux_select(codec, 0, spec->am_entry[i].idx); in snd_hda_gen_mic_autoswitch()
4438 mux_select(codec, 0, spec->am_entry[0].idx); in snd_hda_gen_mic_autoswitch()
4443 static void call_hp_automute(struct hda_codec *codec, in call_hp_automute() argument
4446 struct hda_gen_spec *spec = codec->spec; in call_hp_automute()
4448 spec->hp_automute_hook(codec, jack); in call_hp_automute()
4450 snd_hda_gen_hp_automute(codec, jack); in call_hp_automute()
4453 static void call_line_automute(struct hda_codec *codec, in call_line_automute() argument
4456 struct hda_gen_spec *spec = codec->spec; in call_line_automute()
4458 spec->line_automute_hook(codec, jack); in call_line_automute()
4460 snd_hda_gen_line_automute(codec, jack); in call_line_automute()
4463 static void call_mic_autoswitch(struct hda_codec *codec, in call_mic_autoswitch() argument
4466 struct hda_gen_spec *spec = codec->spec; in call_mic_autoswitch()
4468 spec->mic_autoswitch_hook(codec, jack); in call_mic_autoswitch()
4470 snd_hda_gen_mic_autoswitch(codec, jack); in call_mic_autoswitch()
4474 static void update_automute_all(struct hda_codec *codec) in update_automute_all() argument
4476 call_hp_automute(codec, NULL); in update_automute_all()
4477 call_line_automute(codec, NULL); in update_automute_all()
4478 call_mic_autoswitch(codec, NULL); in update_automute_all()
4487 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in automute_mode_info() local
4488 struct hda_gen_spec *spec = codec->spec; in automute_mode_info()
4501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in automute_mode_get() local
4502 struct hda_gen_spec *spec = codec->spec; in automute_mode_get()
4516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in automute_mode_put() local
4517 struct hda_gen_spec *spec = codec->spec; in automute_mode_put()
4550 call_update_outputs(codec); in automute_mode_put()
4562 static int add_automute_mode_enum(struct hda_codec *codec) in add_automute_mode_enum() argument
4564 struct hda_gen_spec *spec = codec->spec; in add_automute_mode_enum()
4575 static int check_auto_mute_availability(struct hda_codec *codec) in check_auto_mute_availability() argument
4577 struct hda_gen_spec *spec = codec->spec; in check_auto_mute_availability()
4610 if (!is_jack_detectable(codec, nid)) in check_auto_mute_availability()
4612 codec_dbg(codec, "Enable HP auto-muting on NID 0x%x\n", nid); in check_auto_mute_availability()
4613 snd_hda_jack_detect_enable_callback(codec, nid, in check_auto_mute_availability()
4622 if (!is_jack_detectable(codec, nid)) in check_auto_mute_availability()
4624 codec_dbg(codec, "Enable Line-Out auto-muting on NID 0x%x\n", nid); in check_auto_mute_availability()
4625 snd_hda_jack_detect_enable_callback(codec, nid, in check_auto_mute_availability()
4640 err = add_automute_mode_enum(codec); in check_auto_mute_availability()
4648 static bool auto_mic_check_imux(struct hda_codec *codec) in auto_mic_check_imux() argument
4650 struct hda_gen_spec *spec = codec->spec; in auto_mic_check_imux()
4665 snd_hda_jack_detect_enable_callback(codec, in auto_mic_check_imux()
4682 static int check_auto_mic_availability(struct hda_codec *codec) in check_auto_mic_availability() argument
4684 struct hda_gen_spec *spec = codec->spec; in check_auto_mic_availability()
4697 attr = snd_hda_codec_get_pincfg(codec, nid); in check_auto_mic_availability()
4714 if (!is_jack_detectable(codec, nid)) in check_auto_mic_availability()
4736 if (!auto_mic_check_imux(codec)) in check_auto_mic_availability()
4742 codec_dbg(codec, "Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", in check_auto_mic_availability()
4757 unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec, in snd_hda_gen_path_power_filter() argument
4761 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_path_power_filter()
4763 if (!spec->power_down_unused && !codec->power_save_node) in snd_hda_gen_path_power_filter()
4765 if (power_state != AC_PWRST_D0 || nid == codec->core.afg) in snd_hda_gen_path_power_filter()
4767 if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER) in snd_hda_gen_path_power_filter()
4769 if (is_active_nid_for_any(codec, nid)) in snd_hda_gen_path_power_filter()
4776 static void mute_all_mixer_nid(struct hda_codec *codec, hda_nid_t mix) in mute_all_mixer_nid() argument
4782 nums = snd_hda_get_conn_list(codec, mix, &conn); in mute_all_mixer_nid()
4783 has_amp = nid_has_mute(codec, mix, HDA_INPUT); in mute_all_mixer_nid()
4786 update_amp(codec, mix, HDA_INPUT, i, in mute_all_mixer_nid()
4788 else if (nid_has_volume(codec, conn[i], HDA_OUTPUT)) in mute_all_mixer_nid()
4789 update_amp(codec, conn[i], HDA_OUTPUT, 0, in mute_all_mixer_nid()
4802 void snd_hda_gen_stream_pm(struct hda_codec *codec, hda_nid_t nid, bool on) in snd_hda_gen_stream_pm() argument
4804 if (codec->power_save_node) in snd_hda_gen_stream_pm()
4805 set_path_power(codec, nid, -1, on); in snd_hda_gen_stream_pm()
4818 int snd_hda_gen_parse_auto_config(struct hda_codec *codec, in snd_hda_gen_parse_auto_config() argument
4821 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_parse_auto_config()
4824 parse_user_hints(codec); in snd_hda_gen_parse_auto_config()
4839 fill_all_dac_nids(codec); in snd_hda_gen_parse_auto_config()
4865 err = parse_output_paths(codec); in snd_hda_gen_parse_auto_config()
4868 err = create_multi_channel_mode(codec); in snd_hda_gen_parse_auto_config()
4871 err = create_multi_out_ctls(codec, cfg); in snd_hda_gen_parse_auto_config()
4874 err = create_hp_out_ctls(codec); in snd_hda_gen_parse_auto_config()
4877 err = create_speaker_out_ctls(codec); in snd_hda_gen_parse_auto_config()
4880 err = create_indep_hp_ctls(codec); in snd_hda_gen_parse_auto_config()
4883 err = create_loopback_mixing_ctl(codec); in snd_hda_gen_parse_auto_config()
4886 err = create_hp_mic(codec); in snd_hda_gen_parse_auto_config()
4889 err = create_input_ctls(codec); in snd_hda_gen_parse_auto_config()
4894 add_all_pin_power_ctls(codec, false); in snd_hda_gen_parse_auto_config()
4907 err = check_auto_mute_availability(codec); in snd_hda_gen_parse_auto_config()
4911 err = check_dyn_adc_switch(codec); in snd_hda_gen_parse_auto_config()
4915 err = check_auto_mic_availability(codec); in snd_hda_gen_parse_auto_config()
4923 err = parse_capture_source(codec, spec->mixer_nid, in snd_hda_gen_parse_auto_config()
4931 err = create_capture_mixers(codec); in snd_hda_gen_parse_auto_config()
4935 err = parse_mic_boost(codec); in snd_hda_gen_parse_auto_config()
4945 err = create_hp_mic_jack_mode(codec, spec->hp_mic_pin); in snd_hda_gen_parse_auto_config()
4952 err = create_out_jack_modes(codec, cfg->line_outs, in snd_hda_gen_parse_auto_config()
4958 err = create_out_jack_modes(codec, cfg->hp_outs, in snd_hda_gen_parse_auto_config()
4966 add_all_pin_power_ctls(codec, true); in snd_hda_gen_parse_auto_config()
4970 mute_all_mixer_nid(codec, spec->mixer_nid); in snd_hda_gen_parse_auto_config()
4973 parse_digital(codec); in snd_hda_gen_parse_auto_config()
4975 if (spec->power_down_unused || codec->power_save_node) { in snd_hda_gen_parse_auto_config()
4976 if (!codec->power_filter) in snd_hda_gen_parse_auto_config()
4977 codec->power_filter = snd_hda_gen_path_power_filter; in snd_hda_gen_parse_auto_config()
4978 if (!codec->patch_ops.stream_pm) in snd_hda_gen_parse_auto_config()
4979 codec->patch_ops.stream_pm = snd_hda_gen_stream_pm; in snd_hda_gen_parse_auto_config()
4983 err = snd_hda_attach_beep_device(codec, spec->beep_nid); in snd_hda_gen_parse_auto_config()
4986 if (codec->beep && codec->power_save_node) { in snd_hda_gen_parse_auto_config()
4987 err = add_fake_beep_paths(codec); in snd_hda_gen_parse_auto_config()
4990 codec->beep->power_hook = beep_power_hook; in snd_hda_gen_parse_auto_config()
5020 int snd_hda_gen_build_controls(struct hda_codec *codec) in snd_hda_gen_build_controls() argument
5022 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_build_controls()
5026 err = snd_hda_add_new_ctls(codec, spec->kctls.list); in snd_hda_gen_build_controls()
5032 err = snd_hda_create_dig_out_ctls(codec, in snd_hda_gen_build_controls()
5039 err = snd_hda_create_spdif_share_sw(codec, in snd_hda_gen_build_controls()
5047 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); in snd_hda_gen_build_controls()
5054 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { in snd_hda_gen_build_controls()
5055 err = snd_hda_add_vmaster(codec, "Master Playback Volume", in snd_hda_gen_build_controls()
5062 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { in snd_hda_gen_build_controls()
5063 err = __snd_hda_add_vmaster(codec, "Master Playback Switch", in snd_hda_gen_build_controls()
5070 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, in snd_hda_gen_build_controls()
5078 err = snd_hda_jack_add_kctls(codec, &spec->autocfg); in snd_hda_gen_build_controls()
5092 struct hda_codec *codec, in call_pcm_playback_hook() argument
5096 struct hda_gen_spec *spec = codec->spec; in call_pcm_playback_hook()
5098 spec->pcm_playback_hook(hinfo, codec, substream, action); in call_pcm_playback_hook()
5102 struct hda_codec *codec, in call_pcm_capture_hook() argument
5106 struct hda_gen_spec *spec = codec->spec; in call_pcm_capture_hook()
5108 spec->pcm_capture_hook(hinfo, codec, substream, action); in call_pcm_capture_hook()
5115 struct hda_codec *codec, in playback_pcm_open() argument
5118 struct hda_gen_spec *spec = codec->spec; in playback_pcm_open()
5122 err = snd_hda_multi_out_analog_open(codec, in playback_pcm_open()
5127 call_pcm_playback_hook(hinfo, codec, substream, in playback_pcm_open()
5135 struct hda_codec *codec, in playback_pcm_prepare() argument
5140 struct hda_gen_spec *spec = codec->spec; in playback_pcm_prepare()
5143 err = snd_hda_multi_out_analog_prepare(codec, &spec->multiout, in playback_pcm_prepare()
5146 call_pcm_playback_hook(hinfo, codec, substream, in playback_pcm_prepare()
5152 struct hda_codec *codec, in playback_pcm_cleanup() argument
5155 struct hda_gen_spec *spec = codec->spec; in playback_pcm_cleanup()
5158 err = snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); in playback_pcm_cleanup()
5160 call_pcm_playback_hook(hinfo, codec, substream, in playback_pcm_cleanup()
5166 struct hda_codec *codec, in playback_pcm_close() argument
5169 struct hda_gen_spec *spec = codec->spec; in playback_pcm_close()
5172 call_pcm_playback_hook(hinfo, codec, substream, in playback_pcm_close()
5179 struct hda_codec *codec, in capture_pcm_open() argument
5182 call_pcm_capture_hook(hinfo, codec, substream, HDA_GEN_PCM_ACT_OPEN); in capture_pcm_open()
5187 struct hda_codec *codec, in capture_pcm_prepare() argument
5192 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in capture_pcm_prepare()
5193 call_pcm_capture_hook(hinfo, codec, substream, in capture_pcm_prepare()
5199 struct hda_codec *codec, in capture_pcm_cleanup() argument
5202 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in capture_pcm_cleanup()
5203 call_pcm_capture_hook(hinfo, codec, substream, in capture_pcm_cleanup()
5209 struct hda_codec *codec, in capture_pcm_close() argument
5212 call_pcm_capture_hook(hinfo, codec, substream, HDA_GEN_PCM_ACT_CLOSE); in capture_pcm_close()
5217 struct hda_codec *codec, in alt_playback_pcm_open() argument
5220 struct hda_gen_spec *spec = codec->spec; in alt_playback_pcm_open()
5228 call_pcm_playback_hook(hinfo, codec, substream, in alt_playback_pcm_open()
5235 struct hda_codec *codec, in alt_playback_pcm_close() argument
5238 struct hda_gen_spec *spec = codec->spec; in alt_playback_pcm_close()
5241 call_pcm_playback_hook(hinfo, codec, substream, in alt_playback_pcm_close()
5248 struct hda_codec *codec, in alt_playback_pcm_prepare() argument
5253 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in alt_playback_pcm_prepare()
5254 call_pcm_playback_hook(hinfo, codec, substream, in alt_playback_pcm_prepare()
5260 struct hda_codec *codec, in alt_playback_pcm_cleanup() argument
5263 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in alt_playback_pcm_cleanup()
5264 call_pcm_playback_hook(hinfo, codec, substream, in alt_playback_pcm_cleanup()
5273 struct hda_codec *codec, in dig_playback_pcm_open() argument
5276 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_open()
5277 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in dig_playback_pcm_open()
5281 struct hda_codec *codec, in dig_playback_pcm_prepare() argument
5286 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_prepare()
5287 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in dig_playback_pcm_prepare()
5292 struct hda_codec *codec, in dig_playback_pcm_cleanup() argument
5295 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_cleanup()
5296 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); in dig_playback_pcm_cleanup()
5300 struct hda_codec *codec, in dig_playback_pcm_close() argument
5303 struct hda_gen_spec *spec = codec->spec; in dig_playback_pcm_close()
5304 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in dig_playback_pcm_close()
5314 struct hda_codec *codec, in alt_capture_pcm_prepare() argument
5319 struct hda_gen_spec *spec = codec->spec; in alt_capture_pcm_prepare()
5321 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], in alt_capture_pcm_prepare()
5323 call_pcm_capture_hook(hinfo, codec, substream, in alt_capture_pcm_prepare()
5329 struct hda_codec *codec, in alt_capture_pcm_cleanup() argument
5332 struct hda_gen_spec *spec = codec->spec; in alt_capture_pcm_cleanup()
5334 snd_hda_codec_cleanup_stream(codec, in alt_capture_pcm_cleanup()
5336 call_pcm_capture_hook(hinfo, codec, substream, in alt_capture_pcm_cleanup()
5425 static bool dyn_adc_pcm_resetup(struct hda_codec *codec, int cur) in dyn_adc_pcm_resetup() argument
5427 struct hda_gen_spec *spec = codec->spec; in dyn_adc_pcm_resetup()
5432 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); in dyn_adc_pcm_resetup()
5434 snd_hda_codec_setup_stream(codec, new_adc, in dyn_adc_pcm_resetup()
5444 struct hda_codec *codec, in dyn_adc_capture_pcm_prepare() argument
5449 struct hda_gen_spec *spec = codec->spec; in dyn_adc_capture_pcm_prepare()
5453 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); in dyn_adc_capture_pcm_prepare()
5458 struct hda_codec *codec, in dyn_adc_capture_pcm_cleanup() argument
5461 struct hda_gen_spec *spec = codec->spec; in dyn_adc_capture_pcm_cleanup()
5462 snd_hda_codec_cleanup_stream(codec, spec->cur_adc); in dyn_adc_capture_pcm_cleanup()
5530 int snd_hda_gen_build_pcms(struct hda_codec *codec) in snd_hda_gen_build_pcms() argument
5532 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_build_pcms()
5541 " Analog", codec->core.chip_name); in snd_hda_gen_build_pcms()
5542 info = snd_hda_codec_pcm_new(codec, "%s", spec->stream_name_analog); in snd_hda_gen_build_pcms()
5572 " Digital", codec->core.chip_name); in snd_hda_gen_build_pcms()
5573 info = snd_hda_codec_pcm_new(codec, "%s", in snd_hda_gen_build_pcms()
5577 codec->slave_dig_outs = spec->multiout.slave_dig_outs; in snd_hda_gen_build_pcms()
5607 " Alt Analog", codec->core.chip_name); in snd_hda_gen_build_pcms()
5608 info = snd_hda_codec_pcm_new(codec, "%s", in snd_hda_gen_build_pcms()
5644 static void set_output_and_unmute(struct hda_codec *codec, int path_idx) in set_output_and_unmute() argument
5649 path = snd_hda_get_path_from_idx(codec, path_idx); in set_output_and_unmute()
5653 restore_pin_ctl(codec, pin); in set_output_and_unmute()
5654 snd_hda_activate_path(codec, path, path->active, in set_output_and_unmute()
5655 aamix_default(codec->spec)); in set_output_and_unmute()
5656 set_pin_eapd(codec, pin, path->active); in set_output_and_unmute()
5660 static void init_multi_out(struct hda_codec *codec) in init_multi_out() argument
5662 struct hda_gen_spec *spec = codec->spec; in init_multi_out()
5666 set_output_and_unmute(codec, spec->out_paths[i]); in init_multi_out()
5670 static void __init_extra_out(struct hda_codec *codec, int num_outs, int *paths) in __init_extra_out() argument
5675 set_output_and_unmute(codec, paths[i]); in __init_extra_out()
5679 static void init_extra_out(struct hda_codec *codec) in init_extra_out() argument
5681 struct hda_gen_spec *spec = codec->spec; in init_extra_out()
5684 __init_extra_out(codec, spec->autocfg.hp_outs, spec->hp_paths); in init_extra_out()
5686 __init_extra_out(codec, spec->autocfg.speaker_outs, in init_extra_out()
5691 static void init_multi_io(struct hda_codec *codec) in init_multi_io() argument
5693 struct hda_gen_spec *spec = codec->spec; in init_multi_io()
5699 path = get_multiio_path(codec, i); in init_multi_io()
5704 snd_hda_codec_get_pin_target(codec, pin); in init_multi_io()
5705 snd_hda_activate_path(codec, path, path->active, in init_multi_io()
5710 static void init_aamix_paths(struct hda_codec *codec) in init_aamix_paths() argument
5712 struct hda_gen_spec *spec = codec->spec; in init_aamix_paths()
5718 update_aamix_paths(codec, spec->aamix_mode, spec->out_paths[0], in init_aamix_paths()
5721 update_aamix_paths(codec, spec->aamix_mode, spec->hp_paths[0], in init_aamix_paths()
5724 update_aamix_paths(codec, spec->aamix_mode, spec->speaker_paths[0], in init_aamix_paths()
5730 static void init_analog_input(struct hda_codec *codec) in init_analog_input() argument
5732 struct hda_gen_spec *spec = codec->spec; in init_analog_input()
5738 if (is_input_pin(codec, nid)) in init_analog_input()
5739 restore_pin_ctl(codec, nid); in init_analog_input()
5743 resume_path_from_idx(codec, spec->loopback_paths[i]); in init_analog_input()
5744 resume_path_from_idx(codec, spec->loopback_merge_path); in init_analog_input()
5750 static void init_input_src(struct hda_codec *codec) in init_input_src() argument
5752 struct hda_gen_spec *spec = codec->spec; in init_input_src()
5764 path = get_input_path(codec, c, i); in init_input_src()
5769 snd_hda_activate_path(codec, path, active, false); in init_input_src()
5773 update_hp_mic(codec, c, true); in init_input_src()
5777 spec->cap_sync_hook(codec, NULL, NULL); in init_input_src()
5781 static void init_digital(struct hda_codec *codec) in init_digital() argument
5783 struct hda_gen_spec *spec = codec->spec; in init_digital()
5788 set_output_and_unmute(codec, spec->digout_paths[i]); in init_digital()
5791 restore_pin_ctl(codec, pin); in init_digital()
5792 resume_path_from_idx(codec, spec->digin_path); in init_digital()
5799 static void clear_unsol_on_unused_pins(struct hda_codec *codec) in clear_unsol_on_unused_pins() argument
5803 for (i = 0; i < codec->init_pins.used; i++) { in clear_unsol_on_unused_pins()
5804 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); in clear_unsol_on_unused_pins()
5806 if (is_jack_detectable(codec, nid) && in clear_unsol_on_unused_pins()
5807 !snd_hda_jack_tbl_get(codec, nid)) in clear_unsol_on_unused_pins()
5808 snd_hda_codec_update_cache(codec, nid, 0, in clear_unsol_on_unused_pins()
5819 int snd_hda_gen_init(struct hda_codec *codec) in snd_hda_gen_init() argument
5821 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_init()
5824 spec->init_hook(codec); in snd_hda_gen_init()
5826 snd_hda_apply_verbs(codec); in snd_hda_gen_init()
5828 init_multi_out(codec); in snd_hda_gen_init()
5829 init_extra_out(codec); in snd_hda_gen_init()
5830 init_multi_io(codec); in snd_hda_gen_init()
5831 init_aamix_paths(codec); in snd_hda_gen_init()
5832 init_analog_input(codec); in snd_hda_gen_init()
5833 init_input_src(codec); in snd_hda_gen_init()
5834 init_digital(codec); in snd_hda_gen_init()
5836 clear_unsol_on_unused_pins(codec); in snd_hda_gen_init()
5838 sync_all_pin_power_ctls(codec); in snd_hda_gen_init()
5841 update_automute_all(codec); in snd_hda_gen_init()
5843 regcache_sync(codec->core.regmap); in snd_hda_gen_init()
5848 hda_call_check_power_status(codec, 0x01); in snd_hda_gen_init()
5859 void snd_hda_gen_free(struct hda_codec *codec) in snd_hda_gen_free() argument
5861 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE); in snd_hda_gen_free()
5862 snd_hda_gen_spec_free(codec->spec); in snd_hda_gen_free()
5863 kfree(codec->spec); in snd_hda_gen_free()
5864 codec->spec = NULL; in snd_hda_gen_free()
5876 int snd_hda_gen_check_power_status(struct hda_codec *codec, hda_nid_t nid) in snd_hda_gen_check_power_status() argument
5878 struct hda_gen_spec *spec = codec->spec; in snd_hda_gen_check_power_status()
5879 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); in snd_hda_gen_check_power_status()
5904 static int snd_hda_parse_generic_codec(struct hda_codec *codec) in snd_hda_parse_generic_codec() argument
5913 codec->spec = spec; in snd_hda_parse_generic_codec()
5915 err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0); in snd_hda_parse_generic_codec()
5919 err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg); in snd_hda_parse_generic_codec()
5923 codec->patch_ops = generic_patch_ops; in snd_hda_parse_generic_codec()
5927 snd_hda_gen_free(codec); in snd_hda_parse_generic_codec()