Lines Matching defs: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);
1015 unsigned int chs, struct nid_path *path)
1018 if (!path)
1020 val = path->ctls[NID_PATH_VOL_CTL];
1027 /* return the channel bits suitable for the given path->ctls[] */
1028 static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path,
1032 if (path) {
1033 hda_nid_t nid = get_amp_nid_(path->ctls[type]);
1041 struct nid_path *path)
1043 int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL);
1044 return add_vol_ctl(codec, pfx, cidx, chs, path);
1051 unsigned int chs, struct nid_path *path)
1056 if (!path)
1058 val = path->ctls[NID_PATH_MUTE_CTL];
1074 int cidx, struct nid_path *path)
1076 int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL);
1077 return add_sw_ctl(codec, pfx, cidx, chs, path);
1149 /* any ctl assigned to the path with the given index? */
1152 struct nid_path *path = snd_hda_get_path_from_idx(codec, path_idx);
1153 return path && path->ctls[ctl_type];
1272 /* look for widgets in the given path which are appropriate for
1275 * When no appropriate widget is found in the path, the badness value
1279 static int assign_out_path_ctls(struct hda_codec *codec, struct nid_path *path)
1286 if (!path)
1289 if (path->ctls[NID_PATH_VOL_CTL] ||
1290 path->ctls[NID_PATH_MUTE_CTL])
1293 nid = look_for_out_vol_nid(codec, path);
1301 path->ctls[NID_PATH_VOL_CTL] = val;
1304 nid = look_for_out_mute_nid(codec, path);
1315 path->ctls[NID_PATH_MUTE_CTL] = val;
1377 struct nid_path *path;
1381 path = snd_hda_get_path_from_idx(codec, path_idx[i]);
1382 if (path) {
1383 badness += assign_out_path_ctls(codec, path);
1435 path = snd_hda_add_new_path(codec, dac, pin, -spec->mixer_nid);
1436 if (!path && !i && spec->mixer_nid) {
1438 path = snd_hda_add_new_path(codec, dac, pin, 0);
1440 if (!path) {
1444 /* print_nid_path(codec, "output", path); */
1445 path->active = true;
1446 path_idx[i] = snd_hda_get_path_idx(codec, path);
1447 badness += assign_out_path_ctls(codec, path);
1531 struct nid_path *path;
1565 path = snd_hda_add_new_path(codec, dac, nid,
1567 if (!path) {
1571 /* print_nid_path(codec, "multiio", path); */
1575 snd_hda_get_path_idx(codec, path);
1599 path = snd_hda_get_path_from_idx(codec, spec->out_paths[cfg->line_outs + i]);
1600 badness += assign_out_path_ctls(codec, path);
1614 struct nid_path *path;
1621 path = snd_hda_add_new_path(codec, dac, pins[i],
1623 if (!path && !i && spec->mixer_nid)
1624 path = snd_hda_add_new_path(codec, dac, pins[i], 0);
1625 if (path) {
1628 /* print_nid_path(codec, "output", path); */
1629 path->active = true;
1630 path_idx[i] = snd_hda_get_path_idx(codec, path);
1642 /* create a new path including aamix if available, and return its index */
1646 struct nid_path *path;
1649 path = snd_hda_get_path_from_idx(codec, path_idx);
1650 if (!path || !path->depth ||
1651 is_nid_contained(path, spec->mixer_nid))
1653 path_dac = path->path[0];
1655 pin = path->path[path->depth - 1];
1656 path = snd_hda_add_new_path(codec, dac, pin, spec->mixer_nid);
1657 if (!path) {
1667 path = snd_hda_add_new_path(codec, dac, pin,
1670 if (!path)
1672 /* print_nid_path(codec, "output-aamix", path); */
1673 path->active = false; /* unused as default */
1674 path->pin_fixed = true; /* static route */
1675 return snd_hda_get_path_idx(codec, path);
1683 struct nid_path *path;
1690 path = snd_hda_get_path_from_idx(codec, idx);
1691 if (!path)
1694 /* assume no path conflicts unless aamix is involved */
1695 if (!spec->mixer_nid || !is_nid_contained(path, spec->mixer_nid))
1702 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]);
1703 if (path && is_nid_contained(path, spec->mixer_nid))
1707 path = snd_hda_get_path_from_idx(codec, spec->speaker_paths[i]);
1708 if (path && is_nid_contained(path, spec->mixer_nid))
1721 struct nid_path *path;
1727 path = snd_hda_get_path_from_idx(codec, path_idx[i]);
1728 if (!path)
1730 dacs[i] = path->path[0];
1752 /* clear path indices */
1901 struct nid_path *path;
1903 path = snd_hda_get_path_from_idx(codec, idx);
1904 if (path)
1905 print_nid_path(codec, pfx, path);
2065 struct nid_path *path;
2066 path = snd_hda_get_path_from_idx(codec, spec->out_paths[0]);
2067 if (path)
2068 spec->vmaster_nid = look_for_out_vol_nid(codec, path);
2113 struct nid_path *path;
2115 path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]);
2116 if (!path)
2122 err = add_vol_ctl(codec, "Center", 0, 1, path);
2125 err = add_vol_ctl(codec, "LFE", 0, 2, path);
2129 err = add_stereo_vol(codec, name, index, path);
2136 err = add_sw_ctl(codec, "Center", 0, 1, path);
2139 err = add_sw_ctl(codec, "LFE", 0, 2, path);
2143 err = add_stereo_sw(codec, name, index, path);
2154 struct nid_path *path;
2157 path = snd_hda_get_path_from_idx(codec, path_idx);
2158 if (!path)
2160 err = add_stereo_vol(codec, pfx, cidx, path);
2163 err = add_stereo_sw(codec, pfx, cidx, path);
2372 struct nid_path *path;
2374 path = get_multiio_path(codec, idx);
2375 if (!path)
2378 if (path->active == output)
2383 snd_hda_activate_path(codec, path, true, aamix_default(spec));
2387 snd_hda_activate_path(codec, path, false, aamix_default(spec));
2389 path_power_down_sync(codec, path);
2466 /* if HP aamix path is driven from a different DAC and the
2467 * independent HP mode is ON, can't turn on aamix path
2470 mix_path->path[0] != spec->alt_dac_nid)
2489 struct nid_path *path;
2493 path = snd_hda_get_path_from_idx(codec, paths[i]);
2494 if (path)
2495 snd_hda_activate_path(codec, path, path->active,
3049 * aamix path; the amp has to be either in the mixer node or its direct leaf
3092 struct nid_path *path;
3099 path = snd_hda_add_new_path(codec, pin, mix_nid, 0);
3100 if (!path)
3102 print_nid_path(codec, "loopback", path);
3103 spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path);
3105 idx = path->idx[path->depth - 1];
3110 path->ctls[NID_PATH_VOL_CTL] = mix_val;
3117 path->ctls[NID_PATH_MUTE_CTL] = mute_val;
3120 path->active = true;
3121 path->stream_enabled = true; /* no DAC/ADC involved */
3128 path = snd_hda_add_new_path(codec, spec->mixer_nid,
3130 if (path) {
3131 print_nid_path(codec, "loopback-merge", path);
3132 path->active = true;
3133 path->pin_fixed = true; /* static route */
3134 path->stream_enabled = true; /* no DAC/ADC involved */
3136 snd_hda_get_path_idx(codec, path);
3259 struct nid_path *path;
3264 path = snd_hda_add_new_path(codec, pin, adc, anchor);
3265 if (!path)
3267 print_nid_path(codec, "input", path);
3269 snd_hda_get_path_idx(codec, path);
3395 /* get the input path specified by the given adc and imux indices */
3467 struct nid_path *path;
3474 path = get_input_path(codec, adc_idx, i);
3475 if (!path || !path->ctls[type])
3477 kcontrol->private_value = path->ctls[type];
3537 static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path)
3542 path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0;
3544 if (depth >= path->depth)
3546 i = path->depth - depth - 1;
3547 nid = path->path[i];
3548 if (!path->ctls[NID_PATH_VOL_CTL]) {
3550 path->ctls[NID_PATH_VOL_CTL] =
3553 int idx = path->idx[i];
3556 path->ctls[NID_PATH_VOL_CTL] =
3560 if (!path->ctls[NID_PATH_MUTE_CTL]) {
3562 path->ctls[NID_PATH_MUTE_CTL] =
3565 int idx = path->idx[i];
3568 path->ctls[NID_PATH_MUTE_CTL] =
3703 struct nid_path *path;
3707 path = get_input_path(codec, 0, idx);
3708 if (!path)
3710 ctl = path->ctls[type];
3714 path = get_input_path(codec, 0, i);
3715 if (path && path->ctls[type] == ctl)
3780 struct nid_path *path;
3781 path = get_input_path(codec, n, i);
3782 if (!path)
3784 parse_capvol_in_path(codec, path);
3786 vol = path->ctls[NID_PATH_VOL_CTL];
3787 else if (vol != path->ctls[NID_PATH_VOL_CTL]) {
3790 path->ctls[NID_PATH_VOL_CTL], HDA_INPUT))
3794 sw = path->ctls[NID_PATH_MUTE_CTL];
3795 else if (sw != path->ctls[NID_PATH_MUTE_CTL]) {
3798 path->ctls[NID_PATH_MUTE_CTL], HDA_INPUT))
3843 struct nid_path *path)
3850 if (depth >= path->depth - 1)
3852 nid = path->path[depth];
3857 path->idx[depth])) {
3858 val = HDA_COMPOSE_AMP_VAL(nid, 3, path->idx[depth],
3878 struct nid_path *path;
3891 path = get_input_path(codec, 0, i);
3892 if (!path)
3895 val = look_for_boost_amp(codec, path);
3906 path->ctls[NID_PATH_BOOST_CTL] = val;
4139 struct nid_path *path;
4150 path = snd_hda_add_new_path(codec, dig_nid, pin, 0);
4151 if (!path)
4153 print_nid_path(codec, "digout", path);
4154 path->active = true;
4155 path->pin_fixed = true; /* no jack detection */
4156 spec->digout_paths[i] = snd_hda_get_path_idx(codec, path);
4178 path = snd_hda_add_new_path(codec, pin, dig_nid, 0);
4179 if (path) {
4180 print_nid_path(codec, "digin", path);
4181 path->active = true;
4182 path->pin_fixed = true; /* no jack */
4184 spec->digin_path = snd_hda_get_path_idx(codec, path);
4205 struct nid_path *old_path, *path;
4230 path = get_input_path(codec, adc_idx, idx);
4231 if (!path)
4233 if (path->active)
4235 snd_hda_activate_path(codec, path, true, false);
4252 struct nid_path *path;
4255 snd_array_for_each(&spec->paths, n, path) {
4256 if (!path->depth)
4258 if (path->path[0] == nid ||
4259 path->path[path->depth - 1] == nid) {
4260 bool pin_old = path->pin_enabled;
4261 bool stream_old = path->stream_enabled;
4264 path->pin_enabled = pin_state;
4266 path->stream_enabled = stream_state;
4267 if ((!path->pin_fixed && path->pin_enabled != pin_old)
4268 || path->stream_enabled != stream_old) {
4269 last = path_power_update(codec, path, true);
4366 /* sync path power up/down with the jack states of given pins */
4377 /* sync path power up/down with pins; called at init and resume */
4400 struct nid_path *path;
4408 path = snd_array_new(&spec->paths);
4409 if (!path)
4411 memset(path, 0, sizeof(*path));
4412 path->depth = 2;
4413 path->path[0] = nid;
4414 path->path[1] = pins[i];
4415 path->active = true;
4461 struct nid_path *path;
4463 path = snd_array_new(&spec->paths);
4464 if (!path)
4466 memset(path, 0, sizeof(*path));
4467 path->depth = 1;
4468 path->path[0] = pin;
4469 path->active = true;
4470 path->pin_fixed = true;
4471 path->stream_enabled = true;
4517 struct nid_path *path;
4520 path = snd_hda_get_path_from_idx(codec, paths[i]);
4521 if (!path)
4523 mute_nid = get_amp_nid_(path->ctls[NID_PATH_MUTE_CTL]);
5906 /* configure the given path as a proper output */
5909 struct nid_path *path;
5912 path = snd_hda_get_path_from_idx(codec, path_idx);
5913 if (!path || !path->depth)
5915 pin = path->path[path->depth - 1];
5917 snd_hda_activate_path(codec, path, path->active,
5919 set_pin_eapd(codec, pin, path->active);
5961 struct nid_path *path;
5962 path = get_multiio_path(codec, i);
5963 if (!path)
5968 snd_hda_activate_path(codec, path, path->active,
6017 struct nid_path *path;
6027 path = get_input_path(codec, c, i);
6028 if (path) {
6029 bool active = path->active;
6032 snd_hda_activate_path(codec, path, active, false);