diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-01-09 03:14:23 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-01-12 02:44:21 -0500 |
commit | f3fc0b0b1fe31e0ec9a72ab85b421e74c696f00d (patch) | |
tree | 6f80a0b103d00601f7b9566309f40dc088c83870 /sound | |
parent | 3a65bcdc577a338712c2eaefc194909de79d4982 (diff) |
ALSA: hda - Allow aamix as a capture source
Since some codecs can choose the aamix as a capture source, we should
support it as well. When spec->add_stereo_mix_input flag is set, the
parser checks the availability of aamix as the input source, and adds
the paths automatically when possible.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_generic.c | 69 | ||||
-rw-r--r-- | sound/pci/hda/hda_generic.h | 1 |
2 files changed, 45 insertions, 25 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index d16ef1d490fb..26e8d83b5672 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -2067,6 +2067,40 @@ static int check_dyn_adc_switch(struct hda_codec *codec) | |||
2067 | return 0; | 2067 | return 0; |
2068 | } | 2068 | } |
2069 | 2069 | ||
2070 | /* parse capture source paths from the given pin and create imux items */ | ||
2071 | static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin, | ||
2072 | int num_adcs, const char *label, int anchor) | ||
2073 | { | ||
2074 | struct hda_gen_spec *spec = codec->spec; | ||
2075 | struct hda_input_mux *imux = &spec->input_mux; | ||
2076 | int imux_idx = imux->num_items; | ||
2077 | bool imux_added = false; | ||
2078 | int c; | ||
2079 | |||
2080 | for (c = 0; c < num_adcs; c++) { | ||
2081 | struct nid_path *path; | ||
2082 | hda_nid_t adc = spec->adc_nids[c]; | ||
2083 | |||
2084 | if (!is_reachable_path(codec, pin, adc)) | ||
2085 | continue; | ||
2086 | path = snd_hda_add_new_path(codec, pin, adc, anchor); | ||
2087 | if (!path) | ||
2088 | continue; | ||
2089 | print_nid_path("input", path); | ||
2090 | spec->input_paths[imux_idx][c] = | ||
2091 | snd_hda_get_path_idx(codec, path); | ||
2092 | |||
2093 | if (!imux_added) { | ||
2094 | spec->imux_pins[imux->num_items] = pin; | ||
2095 | snd_hda_add_imux_item(imux, label, | ||
2096 | imux->num_items, NULL); | ||
2097 | imux_added = true; | ||
2098 | } | ||
2099 | } | ||
2100 | |||
2101 | return 0; | ||
2102 | } | ||
2103 | |||
2070 | /* | 2104 | /* |
2071 | * create playback/capture controls for input pins | 2105 | * create playback/capture controls for input pins |
2072 | */ | 2106 | */ |
@@ -2075,9 +2109,8 @@ static int create_input_ctls(struct hda_codec *codec) | |||
2075 | struct hda_gen_spec *spec = codec->spec; | 2109 | struct hda_gen_spec *spec = codec->spec; |
2076 | const struct auto_pin_cfg *cfg = &spec->autocfg; | 2110 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
2077 | hda_nid_t mixer = spec->mixer_nid; | 2111 | hda_nid_t mixer = spec->mixer_nid; |
2078 | struct hda_input_mux *imux = &spec->input_mux; | ||
2079 | int num_adcs; | 2112 | int num_adcs; |
2080 | int i, c, err, type_idx = 0; | 2113 | int i, err, type_idx = 0; |
2081 | const char *prev_label = NULL; | 2114 | const char *prev_label = NULL; |
2082 | 2115 | ||
2083 | num_adcs = fill_adc_nids(codec); | 2116 | num_adcs = fill_adc_nids(codec); |
@@ -2087,8 +2120,6 @@ static int create_input_ctls(struct hda_codec *codec) | |||
2087 | for (i = 0; i < cfg->num_inputs; i++) { | 2120 | for (i = 0; i < cfg->num_inputs; i++) { |
2088 | hda_nid_t pin; | 2121 | hda_nid_t pin; |
2089 | const char *label; | 2122 | const char *label; |
2090 | int imux_idx; | ||
2091 | bool imux_added; | ||
2092 | 2123 | ||
2093 | pin = cfg->inputs[i].pin; | 2124 | pin = cfg->inputs[i].pin; |
2094 | if (!is_input_pin(codec, pin)) | 2125 | if (!is_input_pin(codec, pin)) |
@@ -2110,28 +2141,16 @@ static int create_input_ctls(struct hda_codec *codec) | |||
2110 | } | 2141 | } |
2111 | } | 2142 | } |
2112 | 2143 | ||
2113 | imux_added = false; | 2144 | err = parse_capture_source(codec, pin, num_adcs, label, -mixer); |
2114 | imux_idx = imux->num_items; | 2145 | if (err < 0) |
2115 | for (c = 0; c < num_adcs; c++) { | 2146 | return err; |
2116 | struct nid_path *path; | 2147 | } |
2117 | hda_nid_t adc = spec->adc_nids[c]; | ||
2118 | |||
2119 | if (!is_reachable_path(codec, pin, adc)) | ||
2120 | continue; | ||
2121 | path = snd_hda_add_new_path(codec, pin, adc, -mixer); | ||
2122 | if (!path) | ||
2123 | continue; | ||
2124 | print_nid_path("input", path); | ||
2125 | spec->input_paths[imux_idx][c] = | ||
2126 | snd_hda_get_path_idx(codec, path); | ||
2127 | 2148 | ||
2128 | if (!imux_added) { | 2149 | if (mixer && spec->add_stereo_mix_input) { |
2129 | spec->imux_pins[imux->num_items] = pin; | 2150 | err = parse_capture_source(codec, mixer, num_adcs, |
2130 | snd_hda_add_imux_item(imux, label, | 2151 | "Stereo Mix", 0); |
2131 | imux->num_items, NULL); | 2152 | if (err < 0) |
2132 | imux_added = true; | 2153 | return err; |
2133 | } | ||
2134 | } | ||
2135 | } | 2154 | } |
2136 | 2155 | ||
2137 | return 0; | 2156 | return 0; |
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index 1763e33b90ef..89683c7fe263 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h | |||
@@ -190,6 +190,7 @@ struct hda_gen_spec { | |||
190 | unsigned int vmaster_mute_enum:1; /* add vmaster mute mode enum */ | 190 | unsigned int vmaster_mute_enum:1; /* add vmaster mute mode enum */ |
191 | unsigned int indep_hp:1; /* independent HP supported */ | 191 | unsigned int indep_hp:1; /* independent HP supported */ |
192 | unsigned int indep_hp_enabled:1; /* independent HP enabled */ | 192 | unsigned int indep_hp_enabled:1; /* independent HP enabled */ |
193 | unsigned int add_stereo_mix_input:1; /* add aamix as a capture src */ | ||
193 | 194 | ||
194 | /* loopback mixing mode */ | 195 | /* loopback mixing mode */ |
195 | bool aamix_mode; | 196 | bool aamix_mode; |