From fb3409e71f0e5cb3e22327eba2e4d6fbd51d54df Mon Sep 17 00:00:00 2001 From: Tobin Davis Date: Thu, 17 May 2007 09:40:47 +0200 Subject: [ALSA] HDA: Fix headphone mute issue on non-eapd Conexant systems This patch fixes an automute code issue for systems that do not rely on eapd support. Signed-off-by: Tobin Davis Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela --- sound/pci/hda/patch_conexant.c | 48 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index a5a4b2bddf20..bef214bcdddf 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -705,6 +705,17 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = { .get = conexant_mux_enum_get, .put = conexant_mux_enum_put, }, + /* Audio input controls */ + HDA_CODEC_VOLUME("Input-1 Volume", 0x1a, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Input-1 Switch", 0x1a, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Input-2 Volume", 0x1a, 0x1, HDA_INPUT), + HDA_CODEC_MUTE("Input-2 Switch", 0x1a, 0x1, HDA_INPUT), + HDA_CODEC_VOLUME("Input-3 Volume", 0x1a, 0x2, HDA_INPUT), + HDA_CODEC_MUTE("Input-3 Switch", 0x1a, 0x2, HDA_INPUT), + HDA_CODEC_VOLUME("Input-4 Volume", 0x1a, 0x3, HDA_INPUT), + HDA_CODEC_MUTE("Input-4 Switch", 0x1a, 0x3, HDA_INPUT), + HDA_CODEC_VOLUME("Input-5 Volume", 0x1a, 0x4, HDA_INPUT), + HDA_CODEC_MUTE("Input-5 Switch", 0x1a, 0x4, HDA_INPUT), { } /* end */ }; @@ -947,6 +958,23 @@ static void cxt5047_hp_automute(struct hda_codec *codec) snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits); } +/* mute internal speaker if HP is plugged */ +static void cxt5047_hp2_automute(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + unsigned int bits; + + spec->hp_present = snd_hda_codec_read(codec, 0x13, 0, + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; + + bits = spec->hp_present ? 0x80 : 0; + snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits); + snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits); + /* Mute/Unmute PCM 2 for good measure - some systems need this */ + snd_hda_codec_amp_update(codec, 0x1c, 0, HDA_OUTPUT, 0, 0x80, bits); + snd_hda_codec_amp_update(codec, 0x1c, 1, HDA_OUTPUT, 0, 0x80, bits); +} + /* toggle input of built-in and mic jack appropriately */ static void cxt5047_hp_automic(struct hda_codec *codec) { @@ -985,6 +1013,21 @@ static void cxt5047_hp_unsol_event(struct hda_codec *codec, } } +/* unsolicited event for HP jack sensing - non-EAPD systems */ +static void cxt5047_hp2_unsol_event(struct hda_codec *codec, + unsigned int res) +{ + res >>= 26; + switch (res) { + case CONEXANT_HP_EVENT: + cxt5047_hp2_automute(codec); + break; + case CONEXANT_MIC_EVENT: + cxt5047_hp_automic(codec); + break; + } +} + static struct snd_kcontrol_new cxt5047_mixers[] = { HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), @@ -1300,19 +1343,20 @@ static int patch_cxt5047(struct hda_codec *codec) spec->channel_mode = cxt5047_modes, codec->patch_ops = conexant_patch_ops; - codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; board_config = snd_hda_check_board_config(codec, CXT5047_MODELS, cxt5047_models, cxt5047_cfg_tbl); switch (board_config) { case CXT5047_LAPTOP: + codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event; break; case CXT5047_LAPTOP_HP: spec->input_mux = &cxt5047_hp_capture_source; spec->num_init_verbs = 2; spec->init_verbs[1] = cxt5047_hp_init_verbs; spec->mixers[0] = cxt5047_hp_mixers; + codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; codec->patch_ops.init = cxt5047_hp_init; break; case CXT5047_LAPTOP_EAPD: @@ -1320,12 +1364,14 @@ static int patch_cxt5047(struct hda_codec *codec) spec->num_init_verbs = 2; spec->init_verbs[1] = cxt5047_toshiba_init_verbs; spec->mixers[0] = cxt5047_toshiba_mixers; + codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; break; #ifdef CONFIG_SND_DEBUG case CXT5047_TEST: spec->input_mux = &cxt5047_test_capture_source; spec->mixers[0] = cxt5047_test_mixer; spec->init_verbs[0] = cxt5047_test_init_verbs; + codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; #endif } return 0; -- cgit v1.2.3-59-g8ed1b