aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2011-01-05 05:03:56 -0500
committerTakashi Iwai <tiwai@suse.de>2011-01-10 04:57:24 -0500
commit5322bf2790fb91328aac1783bb1963ea3a172bcf (patch)
treebd50875f5748eb97043190ac40a8b87c2db88808 /sound/pci
parent5f99f86a801f937ed51deedc36ad4efc47d95cdd (diff)
ALSA: HDA: Fix volume control indices for Mics (Realtek)
If more than one mic is present with different locations, e g "Front Mic" and "Rear Mic", they can use the same index (0), since their names are different. Previous behavior was to have "Front Mic" as index 1, causing it to be ignored by e g PulseAudio. Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/patch_realtek.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 18d53d2036a3..b4f78952381a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5200,7 +5200,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec,
5200{ 5200{
5201 struct alc_spec *spec = codec->spec; 5201 struct alc_spec *spec = codec->spec;
5202 struct hda_input_mux *imux = &spec->private_imux[0]; 5202 struct hda_input_mux *imux = &spec->private_imux[0];
5203 int i, err, idx, type, type_idx = 0; 5203 int i, err, idx, type_idx = 0;
5204 const char *prev_label = NULL;
5204 5205
5205 for (i = 0; i < cfg->num_inputs; i++) { 5206 for (i = 0; i < cfg->num_inputs; i++) {
5206 hda_nid_t pin; 5207 hda_nid_t pin;
@@ -5210,12 +5211,13 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec,
5210 if (!alc_is_input_pin(codec, pin)) 5211 if (!alc_is_input_pin(codec, pin))
5211 continue; 5212 continue;
5212 5213
5213 type = cfg->inputs[i].type; 5214 label = hda_get_autocfg_input_label(codec, cfg, i);
5214 if (i > 0 && type == cfg->inputs[i - 1].type) 5215 if (prev_label && !strcmp(label, prev_label))
5215 type_idx++; 5216 type_idx++;
5216 else 5217 else
5217 type_idx = 0; 5218 type_idx = 0;
5218 label = hda_get_autocfg_input_label(codec, cfg, i); 5219 prev_label = label;
5220
5219 if (mixer) { 5221 if (mixer) {
5220 idx = get_connection_index(codec, mixer, pin); 5222 idx = get_connection_index(codec, mixer, pin);
5221 if (idx >= 0) { 5223 if (idx >= 0) {
@@ -10819,25 +10821,30 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec)
10819{ 10821{
10820 struct alc_spec *spec = codec->spec; 10822 struct alc_spec *spec = codec->spec;
10821 struct auto_pin_cfg *cfg = &spec->autocfg; 10823 struct auto_pin_cfg *cfg = &spec->autocfg;
10822 int i, err, type; 10824 int i, err;
10823 int type_idx = 0; 10825 int type_idx = 0;
10824 hda_nid_t nid; 10826 hda_nid_t nid;
10827 const char *prev_label = NULL;
10825 10828
10826 for (i = 0; i < cfg->num_inputs; i++) { 10829 for (i = 0; i < cfg->num_inputs; i++) {
10827 if (cfg->inputs[i].type > AUTO_PIN_MIC) 10830 if (cfg->inputs[i].type > AUTO_PIN_MIC)
10828 break; 10831 break;
10829 nid = cfg->inputs[i].pin; 10832 nid = cfg->inputs[i].pin;
10830 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { 10833 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
10831 char label[32]; 10834 const char *label;
10832 type = cfg->inputs[i].type; 10835 char boost_label[32];
10833 if (i > 0 && type == cfg->inputs[i - 1].type) 10836
10837 label = hda_get_autocfg_input_label(codec, cfg, i);
10838 if (prev_label && !strcmp(label, prev_label))
10834 type_idx++; 10839 type_idx++;
10835 else 10840 else
10836 type_idx = 0; 10841 type_idx = 0;
10837 snprintf(label, sizeof(label), "%s Boost Volume", 10842 prev_label = label;
10838 hda_get_autocfg_input_label(codec, cfg, i)); 10843
10839 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 10844 snprintf(boost_label, sizeof(boost_label),
10840 type_idx, 10845 "%s Boost Volume", label);
10846 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10847 boost_label, type_idx,
10841 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 10848 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10842 if (err < 0) 10849 if (err < 0)
10843 return err; 10850 return err;