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

Takashi Iwai tiwai at suse.de
Thu Dec 16 17:22:56 CET 2010


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!


Takashi


> 
> Regards,
> 
> Anisse
> ---
>  sound/pci/hda/patch_realtek.c |   35 +++++++----------------------------
>  1 files changed, 7 insertions(+), 28 deletions(-)
> 
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index 371f698..d58a181 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);
> @@ -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