Lines Matching refs:path

250 /* return true if the given NID is contained in the path */
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;
261 struct nid_path *path;
264 snd_array_for_each(&spec->paths, i, path) {
265 if (path->depth <= 0)
267 if ((!from_nid || path->path[0] == from_nid) &&
268 (!to_nid || path->path[path->depth - 1] == to_nid)) {
270 (anchor_nid > 0 && is_nid_contained(path, anchor_nid)) ||
271 (anchor_nid < 0 && !is_nid_contained(path, anchor_nid)))
272 return path;
279 * snd_hda_get_path_idx - get the index number corresponding to the path
282 * @path: nid_path object
285 * and zero is handled as an invalid path
287 int snd_hda_get_path_idx(struct hda_codec *codec, struct nid_path *path)
295 idx = path - array;
303 * snd_hda_get_path_from_idx - get the path instance corresponding to the
306 * @idx: the path index
322 const struct nid_path *path;
325 snd_array_for_each(&spec->paths, i, path) {
326 if (path->path[0] == nid)
344 /* check whether the given ctl is already assigned in any path elements */
348 const struct nid_path *path;
352 snd_array_for_each(&spec->paths, i, path) {
353 if ((path->ctls[type] & AMP_VAL_COMPARE_MASK) == val)
368 const char *pfx, struct nid_path *path)
375 for (i = 0; i < path->depth; i++)
378 path->path[i]);
380 codec_dbg(codec, "%s path: depth=%d '%s'\n", pfx, path->depth, buf);
386 int anchor_nid, struct nid_path *path,
421 anchor_nid, path, depth + 1))
427 path->path[path->depth] = conn[i];
428 path->idx[path->depth + 1] = i;
430 path->multi[path->depth + 1] = 1;
431 path->depth++;
436 * snd_hda_parse_nid_path - parse the widget path from the given nid to
439 * @from_nid: the NID where the path start from
440 * @to_nid: the NID where the path ends at
442 * @path: the path object to store the result
444 * Returns true if a matching path is found.
452 * when @anchor_nid is zero, no special handling about path selection.
456 struct nid_path *path)
458 if (__parse_nid_path(codec, from_nid, to_nid, anchor_nid, path, 1)) {
459 path->path[path->depth] = to_nid;
460 path->depth++;
467 * snd_hda_add_new_path - parse the path between the given NIDs and
468 * add to the path list
470 * @from_nid: the NID where the path start from
471 * @to_nid: the NID where the path ends at
474 * If no valid path is found, returns NULL.
481 struct nid_path *path;
486 /* check whether the path has been already added */
487 path = get_nid_path(codec, from_nid, to_nid, anchor_nid);
488 if (path)
489 return path;
491 path = snd_array_new(&spec->paths);
492 if (!path)
494 memset(path, 0, sizeof(*path));
495 if (snd_hda_parse_nid_path(codec, from_nid, to_nid, anchor_nid, path))
496 return path;
503 /* clear the given path as invalid so that it won't be picked up later */
506 struct nid_path *path = snd_hda_get_path_from_idx(codec, idx);
507 if (!path)
509 memset(path, 0, sizeof(*path));
564 /* look for a widget suitable for assigning a mute switch in the path */
566 struct nid_path *path)
570 for (i = path->depth - 1; i >= 0; i--) {
571 if (nid_has_mute(codec, path->path[i], HDA_OUTPUT))
572 return path->path[i];
573 if (i != path->depth - 1 && i != 0 &&
574 nid_has_mute(codec, path->path[i], HDA_INPUT))
575 return path->path[i];
580 /* look for a widget suitable for assigning a volume ctl in the path */
582 struct nid_path *path)
587 for (i = path->depth - 1; i >= 0; i--) {
588 hda_nid_t nid = path->path[i];
598 * path activation / deactivation
602 static bool has_amp_in(struct hda_codec *codec, struct nid_path *path, int idx)
604 hda_nid_t nid = path->path[idx];
616 static bool has_amp_out(struct hda_codec *codec, struct nid_path *path, int idx)
618 hda_nid_t nid = path->path[idx];
635 const struct nid_path *path;
641 snd_array_for_each(&spec->paths, n, path) {
642 if (!path->active)
645 if (!path->stream_enabled)
648 if (!(path->pin_enabled || path->pin_fixed) &&
652 for (i = 0; i < path->depth; i++) {
653 if (path->path[i] == nid) {
655 path->idx[i] == idx)
774 static void activate_amp_out(struct hda_codec *codec, struct nid_path *path,
777 hda_nid_t nid = path->path[i];
782 static void activate_amp_in(struct hda_codec *codec, struct nid_path *path,
789 hda_nid_t nid = path->path[i];
800 idx = path->idx[i];
806 * when aa-mixer is available, we need to enable the path as well
822 /* sync power of each widget in the given path */
824 struct nid_path *path,
830 for (i = 0; i < path->depth; i++) {
831 nid = path->path[i];
871 * snd_hda_activate_path - activate or deactivate the given path
873 * @path: the path to activate/deactivate
879 void snd_hda_activate_path(struct hda_codec *codec, struct nid_path *path,
885 path->active = enable;
889 path_power_update(codec, path, codec->power_save_node);
891 for (i = path->depth - 1; i >= 0; i--) {
892 hda_nid_t nid = path->path[i];
894 if (enable && path->multi[i])
897 path->idx[i]);
898 if (has_amp_in(codec, path, i))
899 activate_amp_in(codec, path, i, enable, add_aamix);
900 if (has_amp_out(codec, path, i))
901 activate_amp_out(codec, path, i, enable);
906 /* if the given path is inactive, put widgets into D3 (only if suitable) */
907 static void path_power_down_sync(struct hda_codec *codec, struct nid_path *path)
911 if (!(spec->power_down_unused || codec->power_save_node) || path->active)
913 sync_power_state_change(codec, path_power_update(codec, path, true));
932 /* re-initialize the path specified by the given path index */
935 struct nid_path *path = snd_hda_get_path_from_idx(codec, path_idx);
936 if (path)
937 snd_hda_activate_path(codec, path, path->active, false);
1021 unsigned int chs, struct nid_path *path)
1024 if (!path)
1026 val = path->ctls[NID_PATH_VOL_CTL];
1033 /* return the channel bits suitable for the given path->ctls[] */
1034 static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path,
1038 if (path) {
1039 hda_nid_t nid = get_amp_nid_(path->ctls[type]);
1047 struct nid_path *path)
1049 int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL);
1050 return add_vol_ctl(codec, pfx, cidx, chs, path);
1057 unsigned int chs, struct nid_path *path)
1062 if (!path)
1064 val = path->ctls[NID_PATH_MUTE_CTL];
1080 int cidx, struct nid_path *path)
1082 int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL);
1083 return add_sw_ctl(codec, pfx, cidx, chs, path);
1155 /* any ctl assigned to the path with the given index? */
1158 struct nid_path *path = snd_hda_get_path_from_idx(codec, path_idx);
1159 return path && path->ctls[ctl_type];
1278 /* look for widgets in the given path which are appropriate for
1281 * When no appropriate widget is found in the path, the badness value
1285 static int assign_out_path_ctls(struct hda_codec *codec, struct nid_path *path)
1292 if (!path)
1295 if (path->ctls[NID_PATH_VOL_CTL] ||
1296 path->ctls[NID_PATH_MUTE_CTL])
1299 nid = look_for_out_vol_nid(codec, path);
1307 path->ctls[NID_PATH_VOL_CTL] = val;
1310 nid = look_for_out_mute_nid(codec, path);
1321 path->ctls[NID_PATH_MUTE_CTL] = val;
1383 struct nid_path *path;
1387 path = snd_hda_get_path_from_idx(codec, path_idx[i]);
1388 if (path) {
1389 badness += assign_out_path_ctls(codec, path);
1441 path = snd_hda_add_new_path(codec, dac, pin, -spec->mixer_nid);
1442 if (!path && !i && spec->mixer_nid) {
1444 path = snd_hda_add_new_path(codec, dac, pin, 0);
1446 if (!path) {
1450 /* print_nid_path(codec, "output", path); */
1451 path->active = true;
1452 path_idx[i] = snd_hda_get_path_idx(codec, path);
1453 badness += assign_out_path_ctls(codec, path);
1537 struct nid_path *path;
1571 path = snd_hda_add_new_path(codec, dac, nid,
1573 if (!path) {
1577 /* print_nid_path(codec, "multiio", path); */
1581 snd_hda_get_path_idx(codec, path);
1605 path = snd_hda_get_path_from_idx(codec, spec->out_paths[cfg->line_outs + i]);
1606 badness += assign_out_path_ctls(codec, path);
1620 struct nid_path *path;
1627 path = snd_hda_add_new_path(codec, dac, pins[i],
1629 if (!path && !i && spec->mixer_nid)
1630 path = snd_hda_add_new_path(codec, dac, pins[i], 0);
1631 if (path) {
1634 /* print_nid_path(codec, "output", path); */
1635 path->active = true;
1636 path_idx[i] = snd_hda_get_path_idx(codec, path);
1648 /* create a new path including aamix if available, and return its index */
1652 struct nid_path *path;
1655 path = snd_hda_get_path_from_idx(codec, path_idx);
1656 if (!path || !path->depth ||
1657 is_nid_contained(path, spec->mixer_nid))
1659 path_dac = path->path[0];
1661 pin = path->path[path->depth - 1];
1662 path = snd_hda_add_new_path(codec, dac, pin, spec->mixer_nid);
1663 if (!path) {
1673 path = snd_hda_add_new_path(codec, dac, pin,
1676 if (!path)
1678 /* print_nid_path(codec, "output-aamix", path); */
1679 path->active = false; /* unused as default */
1680 path->pin_fixed = true; /* static route */
1681 return snd_hda_get_path_idx(codec, path);
1689 struct nid_path *path;
1696 path = snd_hda_get_path_from_idx(codec, idx);
1697 if (!path)
1700 /* assume no path conflicts unless aamix is involved */
1701 if (!spec->mixer_nid || !is_nid_contained(path, spec->mixer_nid))
1708 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]);
1709 if (path && is_nid_contained(path, spec->mixer_nid))
1713 path = snd_hda_get_path_from_idx(codec, spec->speaker_paths[i]);
1714 if (path && is_nid_contained(path, spec->mixer_nid))
1727 struct nid_path *path;
1733 path = snd_hda_get_path_from_idx(codec, path_idx[i]);
1734 if (!path)
1736 dacs[i] = path->path[0];
1758 /* clear path indices */
1907 struct nid_path *path;
1909 path = snd_hda_get_path_from_idx(codec, idx);
1910 if (path)
1911 print_nid_path(codec, pfx, path);
2071 struct nid_path *path;
2072 path = snd_hda_get_path_from_idx(codec, spec->out_paths[0]);
2073 if (path)
2074 spec->vmaster_nid = look_for_out_vol_nid(codec, path);
2119 struct nid_path *path;
2121 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]);
2122 if (!path)
2128 err = add_vol_ctl(codec, "Center", 0, 1, path);
2131 err = add_vol_ctl(codec, "LFE", 0, 2, path);
2135 err = add_stereo_vol(codec, name, index, path);
2142 err = add_sw_ctl(codec, "Center", 0, 1, path);
2145 err = add_sw_ctl(codec, "LFE", 0, 2, path);
2149 err = add_stereo_sw(codec, name, index, path);
2160 struct nid_path *path;
2163 path = snd_hda_get_path_from_idx(codec, path_idx);
2164 if (!path)
2166 err = add_stereo_vol(codec, pfx, cidx, path);
2169 err = add_stereo_sw(codec, pfx, cidx, path);
2378 struct nid_path *path;
2380 path = get_multiio_path(codec, idx);
2381 if (!path)
2384 if (path->active == output)
2389 snd_hda_activate_path(codec, path, true, aamix_default(spec));
2393 snd_hda_activate_path(codec, path, false, aamix_default(spec));
2395 path_power_down_sync(codec, path);
2472 /* if HP aamix path is driven from a different DAC and the
2473 * independent HP mode is ON, can't turn on aamix path
2476 mix_path->path[0] != spec->alt_dac_nid)
2495 struct nid_path *path;
2499 path = snd_hda_get_path_from_idx(codec, paths[i]);
2500 if (path)
2501 snd_hda_activate_path(codec, path, path->active,
3055 * aamix path; the amp has to be either in the mixer node or its direct leaf
3098 struct nid_path *path;
3105 path = snd_hda_add_new_path(codec, pin, mix_nid, 0);
3106 if (!path)
3108 print_nid_path(codec, "loopback", path);
3109 spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path);
3111 idx = path->idx[path->depth - 1];
3116 path->ctls[NID_PATH_VOL_CTL] = mix_val;
3123 path->ctls[NID_PATH_MUTE_CTL] = mute_val;
3126 path->active = true;
3127 path->stream_enabled = true; /* no DAC/ADC involved */
3134 path = snd_hda_add_new_path(codec, spec->mixer_nid,
3136 if (path) {
3137 print_nid_path(codec, "loopback-merge", path);
3138 path->active = true;
3139 path->pin_fixed = true; /* static route */
3140 path->stream_enabled = true; /* no DAC/ADC involved */
3142 snd_hda_get_path_idx(codec, path);
3265 struct nid_path *path;
3270 path = snd_hda_add_new_path(codec, pin, adc, anchor);
3271 if (!path)
3273 print_nid_path(codec, "input", path);
3275 snd_hda_get_path_idx(codec, path);
3401 /* get the input path specified by the given adc and imux indices */
3473 struct nid_path *path;
3480 path = get_input_path(codec, adc_idx, i);
3481 if (!path || !path->ctls[type])
3483 kcontrol->private_value = path->ctls[type];
3544 static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path)
3549 path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0;
3551 if (depth >= path->depth)
3553 i = path->depth - depth - 1;
3554 nid = path->path[i];
3555 if (!path->ctls[NID_PATH_VOL_CTL]) {
3557 path->ctls[NID_PATH_VOL_CTL] =
3560 int idx = path->idx[i];
3563 path->ctls[NID_PATH_VOL_CTL] =
3567 if (!path->ctls[NID_PATH_MUTE_CTL]) {
3569 path->ctls[NID_PATH_MUTE_CTL] =
3572 int idx = path->idx[i];
3575 path->ctls[NID_PATH_MUTE_CTL] =
3718 struct nid_path *path;
3722 path = get_input_path(codec, 0, idx);
3723 if (!path)
3725 ctl = path->ctls[type];
3729 path = get_input_path(codec, 0, i);
3730 if (path && path->ctls[type] == ctl)
3795 struct nid_path *path;
3796 path = get_input_path(codec, n, i);
3797 if (!path)
3799 parse_capvol_in_path(codec, path);
3801 vol = path->ctls[NID_PATH_VOL_CTL];
3802 else if (vol != path->ctls[NID_PATH_VOL_CTL]) {
3805 path->ctls[NID_PATH_VOL_CTL], HDA_INPUT))
3809 sw = path->ctls[NID_PATH_MUTE_CTL];
3810 else if (sw != path->ctls[NID_PATH_MUTE_CTL]) {
3813 path->ctls[NID_PATH_MUTE_CTL], HDA_INPUT))
3858 struct nid_path *path)
3865 if (depth >= path->depth - 1)
3867 nid = path->path[depth];
3872 path->idx[depth])) {
3873 val = HDA_COMPOSE_AMP_VAL(nid, 3, path->idx[depth],
3893 struct nid_path *path;
3906 path = get_input_path(codec, 0, i);
3907 if (!path)
3910 val = look_for_boost_amp(codec, path);
3921 path->ctls[NID_PATH_BOOST_CTL] = val;
4028 struct nid_path *path;
4039 path = snd_hda_add_new_path(codec, dig_nid, pin, 0);
4040 if (!path)
4042 print_nid_path(codec, "digout", path);
4043 path->active = true;
4044 path->pin_fixed = true; /* no jack detection */
4045 spec->digout_paths[i] = snd_hda_get_path_idx(codec, path);
4067 path = snd_hda_add_new_path(codec, pin, dig_nid, 0);
4068 if (path) {
4069 print_nid_path(codec, "digin", path);
4070 path->active = true;
4071 path->pin_fixed = true; /* no jack */
4073 spec->digin_path = snd_hda_get_path_idx(codec, path);
4094 struct nid_path *old_path, *path;
4119 path = get_input_path(codec, adc_idx, idx);
4120 if (!path)
4122 if (path->active)
4124 snd_hda_activate_path(codec, path, true, false);
4141 struct nid_path *path;
4144 snd_array_for_each(&spec->paths, n, path) {
4145 if (!path->depth)
4147 if (path->path[0] == nid ||
4148 path->path[path->depth - 1] == nid) {
4149 bool pin_old = path->pin_enabled;
4150 bool stream_old = path->stream_enabled;
4153 path->pin_enabled = pin_state;
4155 path->stream_enabled = stream_state;
4156 if ((!path->pin_fixed && path->pin_enabled != pin_old)
4157 || path->stream_enabled != stream_old) {
4158 last = path_power_update(codec, path, true);
4255 /* sync path power up/down with the jack states of given pins */
4266 /* sync path power up/down with pins; called at init and resume */
4289 struct nid_path *path;
4297 path = snd_array_new(&spec->paths);
4298 if (!path)
4300 memset(path, 0, sizeof(*path));
4301 path->depth = 2;
4302 path->path[0] = nid;
4303 path->path[1] = pins[i];
4304 path->active = true;
4350 struct nid_path *path;
4352 path = snd_array_new(&spec->paths);
4353 if (!path)
4355 memset(path, 0, sizeof(*path));
4356 path->depth = 1;
4357 path->path[0] = pin;
4358 path->active = true;
4359 path->pin_fixed = true;
4360 path->stream_enabled = true;
4406 struct nid_path *path;
4409 path = snd_hda_get_path_from_idx(codec, paths[i]);
4410 if (!path)
4412 mute_nid = get_amp_nid_(path->ctls[NID_PATH_MUTE_CTL]);
5799 /* configure the given path as a proper output */
5802 struct nid_path *path;
5805 path = snd_hda_get_path_from_idx(codec, path_idx);
5806 if (!path || !path->depth)
5808 pin = path->path[path->depth - 1];
5810 snd_hda_activate_path(codec, path, path->active,
5812 set_pin_eapd(codec, pin, path->active);
5854 struct nid_path *path;
5855 path = get_multiio_path(codec, i);
5856 if (!path)
5861 snd_hda_activate_path(codec, path, path->active,
5910 struct nid_path *path;
5920 path = get_input_path(codec, c, i);
5921 if (path) {
5922 bool active = path->active;
5925 snd_hda_activate_path(codec, path, active, false);