Skip to content

Commit e854747

Browse files
KailangYangtiwai
authored andcommitted
ALSA: hda/realtek - Enable headset button support for new codec
This patch will enable headset button for new Chrome platform. Signed-off-by: Kailang Yang <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 911761c commit e854747

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

sound/pci/hda/patch_realtek.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5380,6 +5380,66 @@ static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
53805380
snd_hda_override_wcaps(codec, 0x03, 0);
53815381
}
53825382

5383+
static const struct hda_jack_keymap alc_headset_btn_keymap[] = {
5384+
{ SND_JACK_BTN_0, KEY_PLAYPAUSE },
5385+
{ SND_JACK_BTN_1, KEY_VOICECOMMAND },
5386+
{ SND_JACK_BTN_2, KEY_VOLUMEUP },
5387+
{ SND_JACK_BTN_3, KEY_VOLUMEDOWN },
5388+
{}
5389+
};
5390+
5391+
static void alc_headset_btn_callback(struct hda_codec *codec,
5392+
struct hda_jack_callback *jack)
5393+
{
5394+
int report = 0;
5395+
5396+
if (jack->unsol_res & (7 << 13))
5397+
report |= SND_JACK_BTN_0;
5398+
5399+
if (jack->unsol_res & (1 << 16 | 3 << 8))
5400+
report |= SND_JACK_BTN_1;
5401+
5402+
/* Volume up key */
5403+
if (jack->unsol_res & (7 << 23))
5404+
report |= SND_JACK_BTN_2;
5405+
5406+
/* Volume down key */
5407+
if (jack->unsol_res & (7 << 10))
5408+
report |= SND_JACK_BTN_3;
5409+
5410+
jack->jack->button_state = report;
5411+
}
5412+
5413+
static void alc_fixup_headset_jack(struct hda_codec *codec,
5414+
const struct hda_fixup *fix, int action)
5415+
{
5416+
5417+
switch (action) {
5418+
case HDA_FIXUP_ACT_PRE_PROBE:
5419+
snd_hda_jack_detect_enable_callback(codec, 0x55,
5420+
alc_headset_btn_callback);
5421+
snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack", false,
5422+
SND_JACK_HEADSET, alc_headset_btn_keymap);
5423+
break;
5424+
case HDA_FIXUP_ACT_INIT:
5425+
switch (codec->core.vendor_id) {
5426+
case 0x10ec0225:
5427+
case 0x10ec0295:
5428+
case 0x10ec0299:
5429+
alc_write_coef_idx(codec, 0x48, 0xd011);
5430+
alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
5431+
alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8);
5432+
break;
5433+
case 0x10ec0236:
5434+
case 0x10ec0256:
5435+
alc_write_coef_idx(codec, 0x48, 0xd011);
5436+
alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
5437+
break;
5438+
}
5439+
break;
5440+
}
5441+
}
5442+
53835443
/* for hda_fixup_thinkpad_acpi() */
53845444
#include "thinkpad_helper.c"
53855445

@@ -5517,6 +5577,7 @@ enum {
55175577
ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
55185578
ALC295_FIXUP_HP_AUTO_MUTE,
55195579
ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
5580+
ALC225_FIXUP_HEADSET_JACK,
55205581
};
55215582

55225583
static const struct hda_fixup alc269_fixups[] = {
@@ -6403,6 +6464,10 @@ static const struct hda_fixup alc269_fixups[] = {
64036464
.chained = true,
64046465
.chain_id = ALC269_FIXUP_HEADSET_MIC
64056466
},
6467+
[ALC225_FIXUP_HEADSET_JACK] = {
6468+
.type = HDA_FIXUP_FUNC,
6469+
.v.func = alc_fixup_headset_jack,
6470+
},
64066471
};
64076472

64086473
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -6805,6 +6870,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
68056870
{.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
68066871
{.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
68076872
{.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
6873+
{.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-sense-combo"},
68086874
{}
68096875
};
68106876
#define ALC225_STANDARD_PINS \

0 commit comments

Comments
 (0)