aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_generic.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-05-31 08:10:03 -0400
committerTakashi Iwai <tiwai@suse.de>2013-06-03 05:33:06 -0400
commit77afe0e94884ae40de29cd813a1fb7ddee583591 (patch)
tree89c38b08c64f52168118c32cc299bd1959de0c24 /sound/pci/hda/hda_generic.c
parent087c2e3b4e062573dbbc8a50b9208992e3768dcf (diff)
ALSA: hda - Allow setting automute/automic hooks after parsing
Some codec drivers (VIA codecs and some Realtek fixups) set the automute and automic hooks after calling snd_hda_gen_parse_auto_config(). In the current code, the hook pointers are referred only in snd_hda_gen_parse_auto_config() and passed to snd_hda_jack_detect_enable_callback(), thus changing the hook values won't change the actually called callbacks properly. This patch fixes this bug by setting the static functions as the primary callback functions for the jack detection, and let them calling the appropriate hooks dynamically. Cc: <stable@vger.kernel.org> [v3.9] Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_generic.c')
-rw-r--r--sound/pci/hda/hda_generic.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index ae85bbd2e6f8..fbc10b60be01 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -3875,6 +3875,36 @@ static void update_automute_all(struct hda_codec *codec)
3875 snd_hda_gen_mic_autoswitch(codec, NULL); 3875 snd_hda_gen_mic_autoswitch(codec, NULL);
3876} 3876}
3877 3877
3878/* call appropriate hooks */
3879static void call_hp_automute(struct hda_codec *codec, struct hda_jack_tbl *jack)
3880{
3881 struct hda_gen_spec *spec = codec->spec;
3882 if (spec->hp_automute_hook)
3883 spec->hp_automute_hook(codec, jack);
3884 else
3885 snd_hda_gen_hp_automute(codec, jack);
3886}
3887
3888static void call_line_automute(struct hda_codec *codec,
3889 struct hda_jack_tbl *jack)
3890{
3891 struct hda_gen_spec *spec = codec->spec;
3892 if (spec->line_automute_hook)
3893 spec->line_automute_hook(codec, jack);
3894 else
3895 snd_hda_gen_line_automute(codec, jack);
3896}
3897
3898static void call_mic_autoswitch(struct hda_codec *codec,
3899 struct hda_jack_tbl *jack)
3900{
3901 struct hda_gen_spec *spec = codec->spec;
3902 if (spec->mic_autoswitch_hook)
3903 spec->mic_autoswitch_hook(codec, jack);
3904 else
3905 snd_hda_gen_mic_autoswitch(codec, jack);
3906}
3907
3878/* 3908/*
3879 * Auto-Mute mode mixer enum support 3909 * Auto-Mute mode mixer enum support
3880 */ 3910 */
@@ -4009,9 +4039,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
4009 snd_printdd("hda-codec: Enable HP auto-muting on NID 0x%x\n", 4039 snd_printdd("hda-codec: Enable HP auto-muting on NID 0x%x\n",
4010 nid); 4040 nid);
4011 snd_hda_jack_detect_enable_callback(codec, nid, HDA_GEN_HP_EVENT, 4041 snd_hda_jack_detect_enable_callback(codec, nid, HDA_GEN_HP_EVENT,
4012 spec->hp_automute_hook ? 4042 call_hp_automute);
4013 spec->hp_automute_hook :
4014 snd_hda_gen_hp_automute);
4015 spec->detect_hp = 1; 4043 spec->detect_hp = 1;
4016 } 4044 }
4017 4045
@@ -4024,9 +4052,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
4024 snd_printdd("hda-codec: Enable Line-Out auto-muting on NID 0x%x\n", nid); 4052 snd_printdd("hda-codec: Enable Line-Out auto-muting on NID 0x%x\n", nid);
4025 snd_hda_jack_detect_enable_callback(codec, nid, 4053 snd_hda_jack_detect_enable_callback(codec, nid,
4026 HDA_GEN_FRONT_EVENT, 4054 HDA_GEN_FRONT_EVENT,
4027 spec->line_automute_hook ? 4055 call_line_automute);
4028 spec->line_automute_hook :
4029 snd_hda_gen_line_automute);
4030 spec->detect_lo = 1; 4056 spec->detect_lo = 1;
4031 } 4057 }
4032 spec->automute_lo_possible = spec->detect_hp; 4058 spec->automute_lo_possible = spec->detect_hp;
@@ -4068,9 +4094,7 @@ static bool auto_mic_check_imux(struct hda_codec *codec)
4068 snd_hda_jack_detect_enable_callback(codec, 4094 snd_hda_jack_detect_enable_callback(codec,
4069 spec->am_entry[i].pin, 4095 spec->am_entry[i].pin,
4070 HDA_GEN_MIC_EVENT, 4096 HDA_GEN_MIC_EVENT,
4071 spec->mic_autoswitch_hook ? 4097 call_mic_autoswitch);
4072 spec->mic_autoswitch_hook :
4073 snd_hda_gen_mic_autoswitch);
4074 return true; 4098 return true;
4075} 4099}
4076 4100