[alsa-devel] [PATCH] ALSA: hda - factorize an automute_mic realtek quirk function

Anisse Astier anisse at astier.eu
Thu Dec 16 17:41:48 CET 2010


On Thu, 16 Dec 2010 17:22:56 +0100, Takashi Iwai <tiwai at suse.de> wrote :

> At Thu, 16 Dec 2010 12:19:47 +0100,
> Anisse Astier wrote:
> > 
> > Multiple quirk functions were using the exact same code to verify if the Mic
> > jack was plugged and mute the Mic accordingly
> > 
> > Signed-off-by: Anisse Astier <anisse at astier.eu>
> > ---
> > Hi,
> > 
> > I'm not sure that's the way to go since we loose track of why these functions
> > were written, but sending anyway, it might help see how to have a better
> > quirk management (or best: no quirk at all).
> 
> This is a nice clean-up.  Applied now.
> Thanks!

Maybe you already caught it, but here is a new version of the patch on
top of your for-next branch: a new occurence of the function wasn't
replaced.

Anisse
---

From: Anisse Astier <anisse at astier.eu>
Subject: [PATCH] ALSA: hda - factorize an automute_mic realtek quirk function

Multiple quirk functions were using the exact same code to verify if the
Mic jack was plugged and mute the Mic accordingly.

Signed-off-by: Anisse Astier <anisse at astier.eu>
---
 sound/pci/hda/patch_realtek.c |   37 ++++++++-----------------------------
 1 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 371f698..c83bc66 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3356,7 +3356,7 @@ static struct hda_verb alc880_beep_init_verbs[] = {
 };
 
 /* auto-toggle front mic */
-static void alc880_uniwill_mic_automute(struct hda_codec *codec)
+static void alc88x_simple_mic_automute(struct hda_codec *codec)
 {
  	unsigned int present;
 	unsigned char bits;
@@ -3378,7 +3378,7 @@ static void alc880_uniwill_setup(struct hda_codec *codec)
 static void alc880_uniwill_init_hook(struct hda_codec *codec)
 {
 	alc_automute_amp(codec);
-	alc880_uniwill_mic_automute(codec);
+	alc88x_simple_mic_automute(codec);
 }
 
 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
@@ -3389,7 +3389,7 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
 	 */
 	switch (res >> 28) {
 	case ALC880_MIC_EVENT:
-		alc880_uniwill_mic_automute(codec);
+		alc88x_simple_mic_automute(codec);
 		break;
 	default:
 		alc_automute_amp_unsol_event(codec, res);
@@ -9522,15 +9522,6 @@ static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
 #define alc883_targa_init_hook		alc882_targa_init_hook
 #define alc883_targa_unsol_event	alc882_targa_unsol_event
 
-static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
-{
-	unsigned int present;
-
-	present = snd_hda_jack_detect(codec, 0x18);
-	snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
-				 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
-}
-
 static void alc883_clevo_m720_setup(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
@@ -9542,7 +9533,7 @@ static void alc883_clevo_m720_setup(struct hda_codec *codec)
 static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
 {
 	alc_automute_amp(codec);
-	alc883_clevo_m720_mic_automute(codec);
+	alc88x_simple_mic_automute(codec);
 }
 
 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
@@ -9550,7 +9541,7 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
 {
 	switch (res >> 26) {
 	case ALC880_MIC_EVENT:
-		alc883_clevo_m720_mic_automute(codec);
+		alc88x_simple_mic_automute(codec);
 		break;
 	default:
 		alc_automute_amp_unsol_event(codec, res);
@@ -9809,7 +9800,7 @@ static void alc888_msi_top_unsol_event(struct hda_codec *codec, unsigned int res
 		case ALC880_MIC_EVENT:
 			printk(" is a MIC event\n");
 			//alc_mic_automute(codec);
-			alc880_uniwill_mic_automute(codec);
+			alc88x_simple_mic_automute(codec);
 			break;
 	}
 }
@@ -16806,18 +16797,6 @@ static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
 	{}
 };
 
-static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
-{
-	unsigned int present;
-	unsigned char bits;
-
-	present = snd_hda_jack_detect(codec, 0x18);
-	bits = present ? HDA_AMP_MUTE : 0;
-
-	snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
-				 HDA_AMP_MUTE, bits);
-}
-
 static void alc861vd_lenovo_setup(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
@@ -16828,7 +16807,7 @@ static void alc861vd_lenovo_setup(struct hda_codec *codec)
 static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
 {
 	alc_automute_amp(codec);
-	alc861vd_lenovo_mic_automute(codec);
+	alc88x_simple_mic_automute(codec);
 }
 
 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
@@ -16836,7 +16815,7 @@ static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
 {
 	switch (res >> 26) {
 	case ALC880_MIC_EVENT:
-		alc861vd_lenovo_mic_automute(codec);
+		alc88x_simple_mic_automute(codec);
 		break;
 	default:
 		alc_automute_amp_unsol_event(codec, res);
-- 
1.7.3.2




More information about the Alsa-devel mailing list