Skip to content

Commit 77afe0e

Browse files
committed
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: <[email protected]> [v3.9] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 087c2e3 commit 77afe0e

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

sound/pci/hda/hda_generic.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3875,6 +3875,36 @@ static void update_automute_all(struct hda_codec *codec)
38753875
snd_hda_gen_mic_autoswitch(codec, NULL);
38763876
}
38773877

3878+
/* call appropriate hooks */
3879+
static 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+
3888+
static 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+
3898+
static 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+
38783908
/*
38793909
* Auto-Mute mode mixer enum support
38803910
*/
@@ -4009,9 +4039,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
40094039
snd_printdd("hda-codec: Enable HP auto-muting on NID 0x%x\n",
40104040
nid);
40114041
snd_hda_jack_detect_enable_callback(codec, nid, HDA_GEN_HP_EVENT,
4012-
spec->hp_automute_hook ?
4013-
spec->hp_automute_hook :
4014-
snd_hda_gen_hp_automute);
4042+
call_hp_automute);
40154043
spec->detect_hp = 1;
40164044
}
40174045

@@ -4024,9 +4052,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
40244052
snd_printdd("hda-codec: Enable Line-Out auto-muting on NID 0x%x\n", nid);
40254053
snd_hda_jack_detect_enable_callback(codec, nid,
40264054
HDA_GEN_FRONT_EVENT,
4027-
spec->line_automute_hook ?
4028-
spec->line_automute_hook :
4029-
snd_hda_gen_line_automute);
4055+
call_line_automute);
40304056
spec->detect_lo = 1;
40314057
}
40324058
spec->automute_lo_possible = spec->detect_hp;
@@ -4068,9 +4094,7 @@ static bool auto_mic_check_imux(struct hda_codec *codec)
40684094
snd_hda_jack_detect_enable_callback(codec,
40694095
spec->am_entry[i].pin,
40704096
HDA_GEN_MIC_EVENT,
4071-
spec->mic_autoswitch_hook ?
4072-
spec->mic_autoswitch_hook :
4073-
snd_hda_gen_mic_autoswitch);
4097+
call_mic_autoswitch);
40744098
return true;
40754099
}
40764100

0 commit comments

Comments
 (0)