diff mbox

[Jaunty,2/3] SRU: Toshiba NB200 (Realtek ALC272) mute speakers when headphones are plugged in

Message ID 1257270512.25494.51.camel@emiko
State Accepted
Headers show

Commit Message

Leann Ogasawara Nov. 3, 2009, 5:48 p.m. UTC
>From 13986cae0d540ca8a98ec0a7ca081b44edb2c8e8 Mon Sep 17 00:00:00 2001
From: Leann Ogasawara <leann.ogasawara@canonical.com>
Date: Fri, 21 Aug 2009 13:56:28 -0700
Subject: [PATCH] UBUNTU: SAUCE: Toshiba NB200 (Realtek ALC272) mute speakers when headphones are plugged in

OriginalAuthor: Andres Salomon <dilinger@canonical.com>
OriginalLocation: Hardy LUM netbook-lpia branch
BugLink: http://bugs.launchpad.net/bugs/438318

Mute the speakers when headphones are plugged in for the Toshiba
NB200, Realtek ALC272 (Vendor ID: 0x10ec:0272, Subsystem ID:
0x1179:0xff6e, Revision ID: 0x100001).  Code was forward ported from
Hardy LUM (netbook-lpia branch).

Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
---
 sound/pci/hda/patch_realtek.c |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)

Comments

Stefan Bader Nov. 4, 2009, 3:50 p.m. UTC | #1
The change to alc662_presets[] looks suspicious but on due to the
the patch hints. The patch actually only changes the ALC272_TOSHIBA_NB200
element within that array. So it only changes the newly added model.

Leann Ogasawara wrote:
>>From 13986cae0d540ca8a98ec0a7ca081b44edb2c8e8 Mon Sep 17 00:00:00 2001
> From: Leann Ogasawara <leann.ogasawara@canonical.com>
> Date: Fri, 21 Aug 2009 13:56:28 -0700
> Subject: [PATCH] UBUNTU: SAUCE: Toshiba NB200 (Realtek ALC272) mute speakers when headphones are plugged in
> 
> OriginalAuthor: Andres Salomon <dilinger@canonical.com>
> OriginalLocation: Hardy LUM netbook-lpia branch
> BugLink: http://bugs.launchpad.net/bugs/438318
> 
> Mute the speakers when headphones are plugged in for the Toshiba
> NB200, Realtek ALC272 (Vendor ID: 0x10ec:0272, Subsystem ID:
> 0x1179:0xff6e, Revision ID: 0x100001).  Code was forward ported from
> Hardy LUM (netbook-lpia branch).
> 
> Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>

Acked-by: Stefan Bader <stefan.bader@canonical>

> ---
>  sound/pci/hda/patch_realtek.c |   38 ++++++++++++++++++++++++++++++++++++--
>  1 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index 79710c5..1b9f430 100644
> --- a/sound/pci/hda/patch_realtek.c
> +++ b/sound/pci/hda/patch_realtek.c
> @@ -15646,6 +15646,40 @@ static void alc663_m51va_inithook(struct hda_codec *codec)
>  	alc663_m51va_mic_automute(codec);
>  }
>  
> +static void alc272_toshiba_speaker_automute(struct hda_codec *codec)
> +{
> +	unsigned int present;
> +	unsigned char bits;
> +
> +	present = snd_hda_codec_read(codec, 0x21, 0,
> +			AC_VERB_GET_PIN_SENSE, 0)
> +			& AC_PINSENSE_PRESENCE;
> +	bits = present ? HDA_AMP_MUTE : 0;
> +	snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
> +				AMP_OUT_MUTE, bits);
> +	snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 1,
> +				AMP_OUT_MUTE, bits);
> +}
> +
> +static void alc272_toshiba_unsol_event(struct hda_codec *codec,
> +		unsigned int res)
> +{
> +	switch (res >> 26) {
> +	case ALC880_HP_EVENT:
> +		alc272_toshiba_speaker_automute(codec);
> +		break;
> +	case ALC880_MIC_EVENT:
> +		alc663_m51va_mic_automute(codec);
> +		break;
> +	}
> +}
> +
> +static void alc272_toshiba_inithook(struct hda_codec *codec)
> +{
> +	alc272_toshiba_speaker_automute(codec);
> +	alc663_m51va_mic_automute(codec);
> +}
> +
>  /* ***************** Mode1 ******************************/
>  static void alc663_mode1_unsol_event(struct hda_codec *codec,
>  					   unsigned int res)
> @@ -16086,8 +16120,8 @@ static struct alc_config_preset alc662_presets[] = {
>  		.capsrc_nids = alc662_capsrc_nids,
>  		.channel_mode = alc662_3ST_2ch_modes,
>  		.input_mux = &alc663_m51va_capture_source,
> -		.unsol_event = alc663_m51va_unsol_event,
> -		.init_hook = alc663_m51va_inithook,
> +		.unsol_event = alc272_toshiba_unsol_event,
> +		.init_hook = alc272_toshiba_inithook,
>  	},
>  	[ALC663_ASUS_M51VA] = {
>  		.mixers = { alc663_m51va_mixer, alc662_capture_mixer},
diff mbox

Patch

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 79710c5..1b9f430 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -15646,6 +15646,40 @@  static void alc663_m51va_inithook(struct hda_codec *codec)
 	alc663_m51va_mic_automute(codec);
 }
 
+static void alc272_toshiba_speaker_automute(struct hda_codec *codec)
+{
+	unsigned int present;
+	unsigned char bits;
+
+	present = snd_hda_codec_read(codec, 0x21, 0,
+			AC_VERB_GET_PIN_SENSE, 0)
+			& AC_PINSENSE_PRESENCE;
+	bits = present ? HDA_AMP_MUTE : 0;
+	snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
+				AMP_OUT_MUTE, bits);
+	snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 1,
+				AMP_OUT_MUTE, bits);
+}
+
+static void alc272_toshiba_unsol_event(struct hda_codec *codec,
+		unsigned int res)
+{
+	switch (res >> 26) {
+	case ALC880_HP_EVENT:
+		alc272_toshiba_speaker_automute(codec);
+		break;
+	case ALC880_MIC_EVENT:
+		alc663_m51va_mic_automute(codec);
+		break;
+	}
+}
+
+static void alc272_toshiba_inithook(struct hda_codec *codec)
+{
+	alc272_toshiba_speaker_automute(codec);
+	alc663_m51va_mic_automute(codec);
+}
+
 /* ***************** Mode1 ******************************/
 static void alc663_mode1_unsol_event(struct hda_codec *codec,
 					   unsigned int res)
@@ -16086,8 +16120,8 @@  static struct alc_config_preset alc662_presets[] = {
 		.capsrc_nids = alc662_capsrc_nids,
 		.channel_mode = alc662_3ST_2ch_modes,
 		.input_mux = &alc663_m51va_capture_source,
-		.unsol_event = alc663_m51va_unsol_event,
-		.init_hook = alc663_m51va_inithook,
+		.unsol_event = alc272_toshiba_unsol_event,
+		.init_hook = alc272_toshiba_inithook,
 	},
 	[ALC663_ASUS_M51VA] = {
 		.mixers = { alc663_m51va_mixer, alc662_capture_mixer},