Commit 0e614dd0 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Use direct path reference in assign_out_path_ctls()

Instead of looking through paths with the dac -> pin connection at
each time, just pass the already parsed path index to
assign_out_path_ctls().  This simplifies the code a bit.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent cd5be3f9
...@@ -757,23 +757,26 @@ enum { ...@@ -757,23 +757,26 @@ enum {
BAD_SHARED_VOL = 0x10, BAD_SHARED_VOL = 0x10,
}; };
/* look for widgets in the path between the given NIDs appropriate for /* look for widgets in the given path which are appropriate for
* volume and mute controls, and assign the values to ctls[]. * volume and mute controls, and assign the values to ctls[].
* *
* When no appropriate widget is found in the path, the badness value * When no appropriate widget is found in the path, the badness value
* is incremented depending on the situation. The function returns the * is incremented depending on the situation. The function returns the
* total badness for both volume and mute controls. * total badness for both volume and mute controls.
*/ */
static int assign_out_path_ctls(struct hda_codec *codec, hda_nid_t pin, static int assign_out_path_ctls(struct hda_codec *codec, struct nid_path *path)
hda_nid_t dac)
{ {
struct nid_path *path = snd_hda_get_nid_path(codec, dac, pin);
hda_nid_t nid; hda_nid_t nid;
unsigned int val; unsigned int val;
int badness = 0; int badness = 0;
if (!path) if (!path)
return BAD_SHARED_VOL * 2; return BAD_SHARED_VOL * 2;
if (path->ctls[NID_PATH_VOL_CTL] ||
path->ctls[NID_PATH_MUTE_CTL])
return 0; /* already evaluated */
nid = look_for_out_vol_nid(codec, path); nid = look_for_out_vol_nid(codec, path);
if (nid) { if (nid) {
val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
...@@ -866,8 +869,9 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs, ...@@ -866,8 +869,9 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
struct nid_path *path; struct nid_path *path;
hda_nid_t pin = pins[i]; hda_nid_t pin = pins[i];
if (dacs[i]) { path = snd_hda_get_path_from_idx(codec, path_idx[i]);
badness += assign_out_path_ctls(codec, pin, dacs[i]); if (path) {
badness += assign_out_path_ctls(codec, path);
continue; continue;
} }
...@@ -916,9 +920,8 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs, ...@@ -916,9 +920,8 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
print_nid_path("output", path); print_nid_path("output", path);
path->active = true; path->active = true;
path_idx[i] = snd_hda_get_path_idx(codec, path); path_idx[i] = snd_hda_get_path_idx(codec, path);
badness += assign_out_path_ctls(codec, path);
} }
if (dac)
badness += assign_out_path_ctls(codec, pin, dac);
} }
return badness; return badness;
...@@ -1001,6 +1004,7 @@ static int fill_multi_ios(struct hda_codec *codec, ...@@ -1001,6 +1004,7 @@ static int fill_multi_ios(struct hda_codec *codec,
unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin);
unsigned int location = get_defcfg_location(defcfg); unsigned int location = get_defcfg_location(defcfg);
int badness = 0; int badness = 0;
struct nid_path *path;
old_pins = spec->multi_ios; old_pins = spec->multi_ios;
if (old_pins >= 2) if (old_pins >= 2)
...@@ -1012,7 +1016,6 @@ static int fill_multi_ios(struct hda_codec *codec, ...@@ -1012,7 +1016,6 @@ static int fill_multi_ios(struct hda_codec *codec,
for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
for (i = 0; i < cfg->num_inputs; i++) { for (i = 0; i < cfg->num_inputs; i++) {
struct nid_path *path;
hda_nid_t nid = cfg->inputs[i].pin; hda_nid_t nid = cfg->inputs[i].pin;
hda_nid_t dac = 0; hda_nid_t dac = 0;
...@@ -1067,9 +1070,10 @@ static int fill_multi_ios(struct hda_codec *codec, ...@@ -1067,9 +1070,10 @@ static int fill_multi_ios(struct hda_codec *codec,
} }
/* assign volume and mute controls */ /* assign volume and mute controls */
for (i = old_pins; i < spec->multi_ios; i++) for (i = old_pins; i < spec->multi_ios; i++) {
badness += assign_out_path_ctls(codec, spec->multi_io[i].pin, path = snd_hda_get_path_from_idx(codec, spec->out_paths[cfg->line_outs + i]);
spec->multi_io[i].dac); badness += assign_out_path_ctls(codec, path);
}
return badness; return badness;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment