Lines Matching defs:nid
241 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
245 if (list[i] == nid)
251 static bool is_nid_contained(struct nid_path *path, hda_nid_t nid)
253 return find_idx_in_nid_list(nid, path->path, path->depth) >= 0;
319 static bool is_dac_already_used(struct hda_codec *codec, hda_nid_t nid)
326 if (path->path[0] == nid)
341 /* nid, dir and idx */
359 /* check whether a control with the given (nid, dir, idx) was assigned */
360 static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid,
363 unsigned int val = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
395 return false; /* hit the exclusive nid */
436 * snd_hda_parse_nid_path - parse the widget path from the given nid to
437 * the target nid
535 hda_nid_t nid = spec->all_dacs[i];
536 if (!nid || is_dac_already_used(codec, nid))
538 cap_digital = !!(get_wcaps(codec, nid) & AC_WCAP_DIGITAL);
541 if (is_reachable_path(codec, nid, pin))
542 return nid;
588 hda_nid_t nid = path->path[i];
589 if ((spec->out_vol_mask >> nid) & 1)
591 if (nid_has_volume(codec, nid, HDA_OUTPUT))
592 return nid;
604 hda_nid_t nid = path->path[idx];
605 unsigned int caps = get_wcaps(codec, nid);
618 hda_nid_t nid = path->path[idx];
619 unsigned int caps = get_wcaps(codec, nid);
629 /* check whether the given (nid,dir,idx) is active */
630 static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid,
634 int type = get_wcaps_type(get_wcaps(codec, nid));
638 if (nid == codec->core.afg)
653 if (path->path[i] == nid) {
665 #define is_active_nid_for_any(codec, nid) \
666 is_active_nid(codec, nid, HDA_OUTPUT, -1)
669 static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid,
687 static bool is_stereo_amps(struct hda_codec *codec, hda_nid_t nid, int dir)
689 unsigned int wcaps = get_wcaps(codec, nid);
696 if (snd_hda_get_num_conns(codec, nid) != 1)
698 if (snd_hda_get_connections(codec, nid, &conn, 1) < 0)
704 static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx)
706 unsigned int caps = query_amp_caps(codec, nid, dir);
707 int val = get_amp_val_to_activate(codec, nid, dir, caps, false);
709 if (is_stereo_amps(codec, nid, dir))
710 snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val);
712 snd_hda_codec_amp_init(codec, nid, 0, dir, idx, 0xff, val);
716 static int update_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx,
719 if (is_stereo_amps(codec, nid, dir))
720 return snd_hda_codec_amp_stereo(codec, nid, dir, idx,
723 return snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
731 hda_nid_t nid, int dir, int idx,
737 if (is_ctl_associated(codec, nid, dir, idx, NID_PATH_MUTE_CTL))
741 if (is_ctl_associated(codec, nid, dir, idx, NID_PATH_VOL_CTL) ||
742 is_ctl_associated(codec, nid, dir, idx, NID_PATH_BOOST_CTL))
748 static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir,
754 caps = query_amp_caps(codec, nid, dir);
755 val = get_amp_val_to_activate(codec, nid, dir, caps, enable);
756 mask = get_amp_mask_to_modify(codec, nid, dir, idx_to_check, caps);
761 update_amp(codec, nid, dir, idx, mask, val);
764 static void check_and_activate_amp(struct hda_codec *codec, hda_nid_t nid,
769 if (!enable && is_active_nid(codec, nid, dir, idx_to_check))
771 activate_amp(codec, nid, dir, idx, idx_to_check, enable);
777 hda_nid_t nid = path->path[i];
778 init_amp(codec, nid, HDA_OUTPUT, 0);
779 check_and_activate_amp(codec, nid, HDA_OUTPUT, 0, 0, enable);
789 hda_nid_t nid = path->path[i];
791 nums = snd_hda_get_conn_list(codec, nid, &conn);
794 type = get_wcaps_type(get_wcaps(codec, nid));
803 init_amp(codec, nid, HDA_INPUT, n);
814 activate_amp(codec, nid, HDA_INPUT, n, n, false);
818 check_and_activate_amp(codec, nid, HDA_INPUT, n, idx, enable);
827 hda_nid_t nid, changed = 0;
831 nid = path->path[i];
832 if (!(get_wcaps(codec, nid) & AC_WCAP_POWER))
834 if (nid == codec->core.afg)
836 if (!allow_powerdown || is_active_nid_for_any(codec, nid))
840 power = snd_hda_codec_read(codec, nid, 0,
843 snd_hda_codec_write(codec, nid, 0,
845 changed = nid;
854 snd_hdac_regmap_sync_node(&codec->core, nid);
862 static void sync_power_state_change(struct hda_codec *codec, hda_nid_t nid)
864 if (nid) {
866 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0);
892 hda_nid_t nid = path->path[i];
895 snd_hda_codec_write_cache(codec, nid, 0,
1039 hda_nid_t nid = get_amp_nid_(path->ctls[type]);
1040 if (nid && (get_wcaps(codec, nid) & AC_WCAP_STEREO))
1069 hda_nid_t nid = get_amp_nid_(val);
1070 int nums = snd_hda_get_num_conns(codec, nid);
1094 hda_nid_t nid = get_amp_nid(kcontrol);
1095 bool enabled = !((spec->mute_bits >> nid) & 1);
1286 hda_nid_t nid;
1297 nid = look_for_out_vol_nid(codec, path);
1298 if (nid) {
1299 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
1308 nid = look_for_out_mute_nid(codec, path);
1309 if (nid) {
1310 unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid));
1312 nid_has_mute(codec, nid, HDA_OUTPUT))
1313 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
1315 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT);
1466 hda_nid_t nid = spec->all_dacs[i];
1467 if (!nid || is_dac_already_used(codec, nid))
1469 if (is_reachable_path(codec, nid, pin)) {
1472 nid_found = nid;
1480 unsigned int location, hda_nid_t nid)
1484 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1489 caps = snd_hda_query_pin_caps(codec, nid);
1547 hda_nid_t nid = cfg->inputs[i].pin;
1552 if (!can_be_multiio_pin(codec, location, nid))
1555 if (nid == spec->multi_io[j].pin)
1562 dac = get_dac_if_single(codec, nid);
1564 dac = look_for_dac(codec, nid, false);
1569 path = snd_hda_add_new_path(codec, dac, nid,
1576 spec->multi_io[spec->multi_ios].pin = nid;
1968 hda_nid_t nid;
1972 for_each_hda_codec_node(nid, codec) {
1973 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT)
1979 spec->all_dacs[spec->num_all_dacs++] = nid;
2368 hda_nid_t nid = spec->multi_io[idx].pin;
2379 set_pin_target(codec, nid, PIN_OUT, true);
2381 set_pin_eapd(codec, nid, true);
2383 set_pin_eapd(codec, nid, false);
2385 set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true);
2605 hda_nid_t nid;
2626 nid = 0;
2628 nid = cfg->line_out_pins[0];
2630 nid = cfg->hp_pins[0];
2631 if (!nid)
2634 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN))
2637 cfg->inputs[cfg->num_inputs].pin = nid;
2642 spec->hp_mic_pin = nid;
2645 codec_dbg(codec, "Enable shared I/O jack on NID 0x%x\n", nid);
2669 hda_nid_t nid = kcontrol->private_value;
2670 if (snd_hda_codec_get_pin_target(codec, nid) == PIN_HP)
2681 hda_nid_t nid = kcontrol->private_value;
2685 if (snd_hda_codec_get_pin_target(codec, nid) == val)
2687 snd_hda_set_pin_ctl_cache(codec, nid, val);
2816 hda_nid_t nid = kcontrol->private_value;
2817 unsigned int vref_caps = get_vref_caps(codec, nid);
2831 hda_nid_t nid = kcontrol->private_value;
2832 unsigned int vref_caps = get_vref_caps(codec, nid);
2835 idx = snd_hda_codec_get_pin_target(codec, nid) & AC_PINCTL_VREFEN;
2844 hda_nid_t nid = kcontrol->private_value;
2845 unsigned int vref_caps = get_vref_caps(codec, nid);
2848 val = snd_hda_codec_get_pin_target(codec, nid);
2855 snd_hda_set_pin_ctl_cache(codec, nid, val);
2909 hda_nid_t nid = kcontrol->private_value;
2910 int out_jacks = get_out_jack_num_items(codec, nid);
2911 int in_jacks = get_in_jack_num_items(codec, nid);
2929 unsigned int vref_caps = get_vref_caps(codec, nid);
2939 static int get_cur_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t nid)
2941 int out_jacks = get_out_jack_num_items(codec, nid);
2942 int in_jacks = get_in_jack_num_items(codec, nid);
2943 unsigned int val = snd_hda_codec_get_pin_target(codec, nid);
2952 unsigned int vref_caps = get_vref_caps(codec, nid);
2964 hda_nid_t nid = kcontrol->private_value;
2966 get_cur_hp_mic_jack_mode(codec, nid);
2974 hda_nid_t nid = kcontrol->private_value;
2975 int out_jacks = get_out_jack_num_items(codec, nid);
2976 int in_jacks = get_in_jack_num_items(codec, nid);
2979 oldval = get_cur_hp_mic_jack_mode(codec, nid);
2992 unsigned int vref_caps = get_vref_caps(codec, nid);
2993 val = snd_hda_codec_get_pin_target(codec, nid);
2997 val = snd_hda_get_default_vref(codec, nid) | PIN_IN;
2999 snd_hda_set_pin_ctl_cache(codec, nid, val);
3038 list->nid = mix;
3054 hda_nid_t nid;
3072 nid = list[idx];
3073 if (!*mix_val && nid_has_volume(codec, nid, HDA_OUTPUT) &&
3074 !is_ctl_associated(codec, nid, HDA_OUTPUT, 0, NID_PATH_VOL_CTL))
3075 *mix_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3076 if (!*mute_val && nid_has_mute(codec, nid, HDA_OUTPUT) &&
3077 !is_ctl_associated(codec, nid, HDA_OUTPUT, 0, NID_PATH_MUTE_CTL))
3078 *mute_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3140 static int is_input_pin(struct hda_codec *codec, hda_nid_t nid)
3142 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
3150 hda_nid_t nid;
3155 for_each_hda_codec_node(nid, codec) {
3156 unsigned int caps = get_wcaps(codec, nid);
3161 adc_nids[nums] = nid;
3535 hda_nid_t nid;
3543 nid = path->path[i];
3545 if (nid_has_volume(codec, nid, HDA_OUTPUT))
3547 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3548 else if (nid_has_volume(codec, nid, HDA_INPUT)) {
3553 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT);
3557 if (nid_has_mute(codec, nid, HDA_OUTPUT))
3559 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3560 else if (nid_has_mute(codec, nid, HDA_INPUT)) {
3565 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT);
3572 static bool is_inv_dmic_pin(struct hda_codec *codec, hda_nid_t nid)
3582 if (cfg->inputs[i].pin != nid)
3586 val = snd_hda_codec_get_pincfg(codec, nid);
3828 static bool check_boost_vol(struct hda_codec *codec, hda_nid_t nid,
3833 if (!nid_has_volume(codec, nid, dir) ||
3834 is_ctl_associated(codec, nid, dir, idx, NID_PATH_VOL_CTL) ||
3835 is_ctl_associated(codec, nid, dir, idx, NID_PATH_BOOST_CTL))
3838 step = (query_amp_caps(codec, nid, dir) & AC_AMPCAP_STEP_SIZE)
3850 hda_nid_t nid;
3856 nid = path->path[depth];
3857 if (depth && check_boost_vol(codec, nid, HDA_OUTPUT, 0)) {
3858 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3860 } else if (check_boost_vol(codec, nid, HDA_INPUT,
3862 val = HDA_COMPOSE_AMP_VAL(nid, 3, path->idx[depth],
4124 static hda_nid_t set_path_power(struct hda_codec *codec, hda_nid_t nid,
4135 if (path->path[0] == nid ||
4136 path->path[path->depth - 1] == nid) {
4188 if (jack && jack->nid)
4190 set_pin_power_jack(codec, jack->nid, on));
4273 static int add_fake_paths(struct hda_codec *codec, hda_nid_t nid,
4283 if (get_nid_path(codec, nid, pins[i], 0))
4290 path->path[0] = nid;
4302 hda_nid_t nid = spec->beep_nid;
4305 if (!codec->power_save_node || !nid)
4307 err = add_fake_paths(codec, nid, cfg->line_outs, cfg->line_out_pins);
4311 err = add_fake_paths(codec, nid, cfg->hp_outs, cfg->hp_pins);
4316 err = add_fake_paths(codec, nid, cfg->speaker_outs,
4327 set_path_power(beep->codec, beep->nid, -1, on);
4364 hda_nid_t nid = pins[i];
4365 if (!nid)
4368 if (snd_hda_codec_get_pin_target(codec, nid) & AC_PINCTL_IN_EN)
4370 if (snd_hda_jack_detect_state(codec, nid) == HDA_JACK_PRESENT)
4384 hda_nid_t nid = pins[i];
4386 if (!nid)
4389 oldval = snd_hda_codec_get_pin_target(codec, nid);
4423 update_pin_ctl(codec, nid, val);
4426 set_pin_eapd(codec, nid, !mute);
4430 on = detect_pin_state(codec, nid);
4431 set_path_power(codec, nid, on, -1);
4747 hda_nid_t nid = cfg->hp_pins[i];
4748 if (!is_jack_detectable(codec, nid))
4750 codec_dbg(codec, "Enable HP auto-muting on NID 0x%x\n", nid);
4751 snd_hda_jack_detect_enable_callback(codec, nid,
4759 hda_nid_t nid = cfg->line_out_pins[i];
4760 if (!is_jack_detectable(codec, nid))
4762 codec_dbg(codec, "Enable Line-Out auto-muting on NID 0x%x\n", nid);
4763 snd_hda_jack_detect_enable_callback(codec, nid,
4833 hda_nid_t nid = cfg->inputs[i].pin;
4835 attr = snd_hda_codec_get_pincfg(codec, nid);
4852 if (!is_jack_detectable(codec, nid))
4859 spec->am_entry[num_pins].pin = nid;
4892 * @nid: NID to evalute
4896 hda_nid_t nid,
4903 if (power_state != AC_PWRST_D0 || nid == codec->core.afg)
4905 if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER)
4907 if (is_active_nid_for_any(codec, nid))
4935 * @nid: audio widget
4940 void snd_hda_gen_stream_pm(struct hda_codec *codec, hda_nid_t nid, bool on)
4943 set_path_power(codec, nid, -1, on);
4948 static bool force_mute_output_path(struct hda_codec *codec, hda_nid_t nid)
4950 if (!nid)
4952 if (!nid_has_mute(codec, nid, HDA_OUTPUT))
4954 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4955 snd_hda_codec_amp_read(codec, nid, 1, HDA_OUTPUT, 0) &
4960 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5395 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format);
5405 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
5455 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format);
5465 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
5675 .nid = 0, /* fill later */
5702 * from @spec_str and @nid
5707 hda_nid_t nid)
5710 if (nid)
5711 str->nid = nid;
5941 hda_nid_t nid = cfg->inputs[i].pin;
5942 if (is_input_pin(codec, nid))
5943 restore_pin_ctl(codec, nid);
6009 hda_nid_t nid = pin->nid;
6010 if (is_jack_detectable(codec, nid) &&
6011 !snd_hda_jack_tbl_get(codec, nid))
6012 snd_hda_codec_write_cache(codec, nid, 0,
6076 * @nid: NID to inspect
6080 int snd_hda_gen_check_power_status(struct hda_codec *codec, hda_nid_t nid)
6083 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);