diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-01-04 07:19:55 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-01-12 02:43:31 -0500 |
commit | f5172a7ed966493414aa58319fbb7ab0a80cf889 (patch) | |
tree | 0e22c823df8271bc93a0f55674c0f350c09bf4b3 | |
parent | 1e0b528696edf20ad38f494dda49c6195bee1b7f (diff) |
ALSA: hda - Check the existing path in snd_hda_add_new_path()
If the requested path has been already added, return the existing path
instance instead of adding a duplicated instance.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/hda/hda_generic.c | 31 | ||||
-rw-r--r-- | sound/pci/hda/hda_generic.h | 1 |
2 files changed, 25 insertions, 7 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index ee2c973f9125..f9ecbe09a526 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -116,11 +116,9 @@ EXPORT_SYMBOL_HDA(snd_hda_gen_spec_free); | |||
116 | * parsing paths | 116 | * parsing paths |
117 | */ | 117 | */ |
118 | 118 | ||
119 | /* get the path between the given NIDs; | 119 | static struct nid_path *get_nid_path(struct hda_codec *codec, |
120 | * passing 0 to either @pin or @dac behaves as a wildcard | 120 | hda_nid_t from_nid, hda_nid_t to_nid, |
121 | */ | 121 | int with_aa_mix) |
122 | struct nid_path *snd_hda_get_nid_path(struct hda_codec *codec, | ||
123 | hda_nid_t from_nid, hda_nid_t to_nid) | ||
124 | { | 122 | { |
125 | struct hda_gen_spec *spec = codec->spec; | 123 | struct hda_gen_spec *spec = codec->spec; |
126 | int i; | 124 | int i; |
@@ -130,11 +128,23 @@ struct nid_path *snd_hda_get_nid_path(struct hda_codec *codec, | |||
130 | if (path->depth <= 0) | 128 | if (path->depth <= 0) |
131 | continue; | 129 | continue; |
132 | if ((!from_nid || path->path[0] == from_nid) && | 130 | if ((!from_nid || path->path[0] == from_nid) && |
133 | (!to_nid || path->path[path->depth - 1] == to_nid)) | 131 | (!to_nid || path->path[path->depth - 1] == to_nid)) { |
134 | return path; | 132 | if (with_aa_mix == HDA_PARSE_ALL || |
133 | path->with_aa_mix == with_aa_mix) | ||
134 | return path; | ||
135 | } | ||
135 | } | 136 | } |
136 | return NULL; | 137 | return NULL; |
137 | } | 138 | } |
139 | |||
140 | /* get the path between the given NIDs; | ||
141 | * passing 0 to either @pin or @dac behaves as a wildcard | ||
142 | */ | ||
143 | struct nid_path *snd_hda_get_nid_path(struct hda_codec *codec, | ||
144 | hda_nid_t from_nid, hda_nid_t to_nid) | ||
145 | { | ||
146 | return get_nid_path(codec, from_nid, to_nid, HDA_PARSE_ALL); | ||
147 | } | ||
138 | EXPORT_SYMBOL_HDA(snd_hda_get_nid_path); | 148 | EXPORT_SYMBOL_HDA(snd_hda_get_nid_path); |
139 | 149 | ||
140 | /* check whether the given DAC is already found in any existing paths */ | 150 | /* check whether the given DAC is already found in any existing paths */ |
@@ -248,6 +258,8 @@ static bool __parse_nid_path(struct hda_codec *codec, | |||
248 | 258 | ||
249 | found: | 259 | found: |
250 | path->path[path->depth] = conn[i]; | 260 | path->path[path->depth] = conn[i]; |
261 | if (conn[i] == spec->mixer_nid) | ||
262 | path->with_aa_mix = true; | ||
251 | path->idx[path->depth + 1] = i; | 263 | path->idx[path->depth + 1] = i; |
252 | if (nums > 1 && get_wcaps_type(get_wcaps(codec, to_nid)) != AC_WID_AUD_MIX) | 264 | if (nums > 1 && get_wcaps_type(get_wcaps(codec, to_nid)) != AC_WID_AUD_MIX) |
253 | path->multi[path->depth + 1] = 1; | 265 | path->multi[path->depth + 1] = 1; |
@@ -290,6 +302,11 @@ snd_hda_add_new_path(struct hda_codec *codec, hda_nid_t from_nid, | |||
290 | if (from_nid && to_nid && !is_reachable_path(codec, from_nid, to_nid)) | 302 | if (from_nid && to_nid && !is_reachable_path(codec, from_nid, to_nid)) |
291 | return NULL; | 303 | return NULL; |
292 | 304 | ||
305 | /* check whether the path has been already added */ | ||
306 | path = get_nid_path(codec, from_nid, to_nid, with_aa_mix); | ||
307 | if (path) | ||
308 | return path; | ||
309 | |||
293 | path = snd_array_new(&spec->paths); | 310 | path = snd_array_new(&spec->paths); |
294 | if (!path) | 311 | if (!path) |
295 | return NULL; | 312 | return NULL; |
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index 1090a524755b..f1cae2e49377 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h | |||
@@ -53,6 +53,7 @@ struct nid_path { | |||
53 | unsigned char multi[MAX_NID_PATH_DEPTH]; | 53 | unsigned char multi[MAX_NID_PATH_DEPTH]; |
54 | unsigned int ctls[NID_PATH_NUM_CTLS]; /* NID_PATH_XXX_CTL */ | 54 | unsigned int ctls[NID_PATH_NUM_CTLS]; /* NID_PATH_XXX_CTL */ |
55 | bool active; | 55 | bool active; |
56 | bool with_aa_mix; | ||
56 | }; | 57 | }; |
57 | 58 | ||
58 | /* mic/line-in auto switching entry */ | 59 | /* mic/line-in auto switching entry */ |