Skip to contentSkip to conversation

ALSA: hda - Fix calling cs_automic twice for Cirrus codecs.

PATCH Applied Dylan Reid 2 participants 2 messages Jan 31, 2012 – Feb 1, 2012 Sound

lore
Share & tools
lore

Dylan Reid

author
#0 lore raw

PATCH 1/1 ALSA: hda - Fix calling cs_automic twice for Cirrus codecs.

If cs_automic is called twice (like it is during init) while the mic is present, it will over-write the last_input with the new one, causing it to switch back to the automic input when the mic is unplugged. This leaves the driver in a state (cur_input, last_input, and automix_idx the same) where the internal mic can not be selected until it is rebooted without the mic attached.

Check that the mic hasn't already been switched to before setting last_input.

---
 sound/pci/hda/patch_cirrus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
sound/pci/hda/patch_cirrus.c +4 -2
index 0e99357..bc5a993 100644
@@ -988,8 +988,10 @@ static void cs_automic(struct hda_codec *codec)
 			change_cur_input(codec, !spec->automic_idx, 0);
 	} else {
 		if (present) {
-			spec->last_input = spec->cur_input;
-			spec->cur_input = spec->automic_idx;
+			if (spec->cur_input != spec->automic_idx) {
+				spec->last_input = spec->cur_input;
+				spec->cur_input = spec->automic_idx;
+			}
 		} else  {
 			spec->cur_input = spec->last_input;
 		}
Signature · 1 line
1.7.9.rc0
Applied
#1 lore raw

At Tue, 31 Jan 2012 13:04:41 -0800,

Quoted 8 lines · Dylan Reid

If cs_automic is called twice (like it is during init) while the mic is present, it will over-write the last_input with the new one, causing it to switch back to the automic input when the mic is unplugged. This leaves the driver in a state (cur_input, last_input, and automix_idx the same) where the internal mic can not be selected until it is rebooted without the mic attached.

Quoted 4 lines

Check that the mic hasn't already been switched to before setting last_input.

Thanks, applied now.

Takashi

Quoted 24 lines
---
 sound/pci/hda/patch_cirrus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
sound/pci/hda/patch_cirrus.c +4 -2
index 0e99357..bc5a993 100644
@@ -988,8 +988,10 @@ static void cs_automic(struct hda_codec *codec)
 			change_cur_input(codec, !spec->automic_idx, 0);
 	} else {
 		if (present) {
-			spec->last_input = spec->cur_input;
-			spec->cur_input = spec->automic_idx;
+			if (spec->cur_input != spec->automic_idx) {
+				spec->last_input = spec->cur_input;
+				spec->cur_input = spec->automic_idx;
+			}
 		} else  {
 			spec->cur_input = spec->last_input;
 		}
Signature · 1 line
1.7.9.rc0