diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-02-07 04:45:11 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-02-07 04:45:11 -0500 |
commit | 0186f4f4f248d00a2bfcd7c305cfec12fa8e5e30 (patch) | |
tree | 82ad54f92327772ed6fee19638b396d9eb54f0d0 /sound | |
parent | 46a144818acd8b340bdc6ccf12255c7fb301f0ee (diff) |
ALSA: hda - Use generic array for loopback list management
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_generic.c | 18 | ||||
-rw-r--r-- | sound/pci/hda/hda_generic.h | 3 | ||||
-rw-r--r-- | sound/pci/hda/patch_via.c | 8 |
3 files changed, 17 insertions, 12 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index c2cd3d6b6003..6af5aded1ed5 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -42,6 +42,7 @@ int snd_hda_gen_spec_init(struct hda_gen_spec *spec) | |||
42 | { | 42 | { |
43 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); | 43 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
44 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); | 44 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); |
45 | snd_array_init(&spec->loopback_list, sizeof(struct hda_amp_list), 8); | ||
45 | mutex_init(&spec->pcm_mutex); | 46 | mutex_init(&spec->pcm_mutex); |
46 | return 0; | 47 | return 0; |
47 | } | 48 | } |
@@ -82,6 +83,7 @@ void snd_hda_gen_spec_free(struct hda_gen_spec *spec) | |||
82 | return; | 83 | return; |
83 | free_kctls(spec); | 84 | free_kctls(spec); |
84 | snd_array_free(&spec->paths); | 85 | snd_array_free(&spec->paths); |
86 | snd_array_free(&spec->loopback_list); | ||
85 | } | 87 | } |
86 | EXPORT_SYMBOL_HDA(snd_hda_gen_spec_free); | 88 | EXPORT_SYMBOL_HDA(snd_hda_gen_spec_free); |
87 | 89 | ||
@@ -2484,18 +2486,18 @@ static int create_in_jack_mode(struct hda_codec *codec, hda_nid_t pin) | |||
2484 | */ | 2486 | */ |
2485 | 2487 | ||
2486 | /* add the powersave loopback-list entry */ | 2488 | /* add the powersave loopback-list entry */ |
2487 | static void add_loopback_list(struct hda_gen_spec *spec, hda_nid_t mix, int idx) | 2489 | static int add_loopback_list(struct hda_gen_spec *spec, hda_nid_t mix, int idx) |
2488 | { | 2490 | { |
2489 | struct hda_amp_list *list; | 2491 | struct hda_amp_list *list; |
2490 | 2492 | ||
2491 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) | 2493 | list = snd_array_new(&spec->loopback_list); |
2492 | return; | 2494 | if (!list) |
2493 | list = spec->loopback_list + spec->num_loopbacks; | 2495 | return -ENOMEM; |
2494 | list->nid = mix; | 2496 | list->nid = mix; |
2495 | list->dir = HDA_INPUT; | 2497 | list->dir = HDA_INPUT; |
2496 | list->idx = idx; | 2498 | list->idx = idx; |
2497 | spec->num_loopbacks++; | 2499 | spec->loopback.amplist = spec->loopback_list.list; |
2498 | spec->loopback.amplist = spec->loopback_list; | 2500 | return 0; |
2499 | } | 2501 | } |
2500 | 2502 | ||
2501 | /* create input playback/capture controls for the given pin */ | 2503 | /* create input playback/capture controls for the given pin */ |
@@ -2536,7 +2538,9 @@ static int new_analog_input(struct hda_codec *codec, int input_idx, | |||
2536 | } | 2538 | } |
2537 | 2539 | ||
2538 | path->active = true; | 2540 | path->active = true; |
2539 | add_loopback_list(spec, mix_nid, idx); | 2541 | err = add_loopback_list(spec, mix_nid, idx); |
2542 | if (err < 0) | ||
2543 | return err; | ||
2540 | 2544 | ||
2541 | if (spec->mixer_nid != spec->mixer_merge_nid && | 2545 | if (spec->mixer_nid != spec->mixer_merge_nid && |
2542 | !spec->loopback_merge_path) { | 2546 | !spec->loopback_merge_path) { |
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index d5348dd7a14f..009b57be96d3 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h | |||
@@ -228,8 +228,7 @@ struct hda_gen_spec { | |||
228 | struct hda_vmaster_mute_hook vmaster_mute; | 228 | struct hda_vmaster_mute_hook vmaster_mute; |
229 | 229 | ||
230 | struct hda_loopback_check loopback; | 230 | struct hda_loopback_check loopback; |
231 | int num_loopbacks; | 231 | struct snd_array loopback_list; |
232 | struct hda_amp_list loopback_list[8]; | ||
233 | 232 | ||
234 | /* multi-io */ | 233 | /* multi-io */ |
235 | int multi_ios; | 234 | int multi_ios; |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index ca7d962a08a6..c35338a8771d 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -355,10 +355,12 @@ static bool is_aa_path_mute(struct hda_codec *codec) | |||
355 | { | 355 | { |
356 | struct via_spec *spec = codec->spec; | 356 | struct via_spec *spec = codec->spec; |
357 | const struct hda_amp_list *p; | 357 | const struct hda_amp_list *p; |
358 | int i, ch, v; | 358 | int ch, v; |
359 | 359 | ||
360 | for (i = 0; i < spec->gen.num_loopbacks; i++) { | 360 | p = spec->gen.loopback.amplist; |
361 | p = &spec->gen.loopback_list[i]; | 361 | if (!p) |
362 | return true; | ||
363 | for (; p->nid; p++) { | ||
362 | for (ch = 0; ch < 2; ch++) { | 364 | for (ch = 0; ch < 2; ch++) { |
363 | v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, | 365 | v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, |
364 | p->idx); | 366 | p->idx); |