Skip to content

Commit a2d57eb

Browse files
kasper93tiwai
authored andcommitted
ALSA: hda/realtek: Add speaker AMP init for Samsung laptops with ALC298
Magic initialization sequence was extracted from Windows driver and cleaned up manually. Fixes internal speakers output. Link: https://bugzilla.kernel.org/show_bug.cgi?id=207423 Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1851518 Signed-off-by: Kacper Michajłow <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 5934d9a commit a2d57eb

File tree

1 file changed

+56
-7
lines changed

1 file changed

+56
-7
lines changed

sound/pci/hda/patch_realtek.c

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4700,6 +4700,48 @@ static void alc236_fixup_hp_mute_led_micmute_vref(struct hda_codec *codec,
47004700
alc236_fixup_hp_micmute_led_vref(codec, fix, action);
47014701
}
47024702

4703+
static inline void alc298_samsung_write_coef_pack(struct hda_codec *codec,
4704+
const unsigned short coefs[2])
4705+
{
4706+
alc_write_coef_idx(codec, 0x23, coefs[0]);
4707+
alc_write_coef_idx(codec, 0x25, coefs[1]);
4708+
alc_write_coef_idx(codec, 0x26, 0xb011);
4709+
}
4710+
4711+
struct alc298_samsung_amp_desc {
4712+
unsigned char nid;
4713+
unsigned short init_seq[2][2];
4714+
};
4715+
4716+
static void alc298_fixup_samsung_amp(struct hda_codec *codec,
4717+
const struct hda_fixup *fix, int action)
4718+
{
4719+
int i, j;
4720+
static const unsigned short init_seq[][2] = {
4721+
{ 0x19, 0x00 }, { 0x20, 0xc0 }, { 0x22, 0x44 }, { 0x23, 0x08 },
4722+
{ 0x24, 0x85 }, { 0x25, 0x41 }, { 0x35, 0x40 }, { 0x36, 0x01 },
4723+
{ 0x38, 0x81 }, { 0x3a, 0x03 }, { 0x3b, 0x81 }, { 0x40, 0x3e },
4724+
{ 0x41, 0x07 }, { 0x400, 0x1 }
4725+
};
4726+
static const struct alc298_samsung_amp_desc amps[] = {
4727+
{ 0x3a, { { 0x18, 0x1 }, { 0x26, 0x0 } } },
4728+
{ 0x39, { { 0x18, 0x2 }, { 0x26, 0x1 } } }
4729+
};
4730+
4731+
if (action != HDA_FIXUP_ACT_INIT)
4732+
return;
4733+
4734+
for (i = 0; i < ARRAY_SIZE(amps); i++) {
4735+
alc_write_coef_idx(codec, 0x22, amps[i].nid);
4736+
4737+
for (j = 0; j < ARRAY_SIZE(amps[i].init_seq); j++)
4738+
alc298_samsung_write_coef_pack(codec, amps[i].init_seq[j]);
4739+
4740+
for (j = 0; j < ARRAY_SIZE(init_seq); j++)
4741+
alc298_samsung_write_coef_pack(codec, init_seq[j]);
4742+
}
4743+
}
4744+
47034745
#if IS_REACHABLE(CONFIG_INPUT)
47044746
static void gpio2_mic_hotkey_event(struct hda_codec *codec,
47054747
struct hda_jack_callback *event)
@@ -7030,6 +7072,7 @@ enum {
70307072
ALC236_FIXUP_HP_GPIO_LED,
70317073
ALC236_FIXUP_HP_MUTE_LED,
70327074
ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
7075+
ALC298_FIXUP_SAMSUNG_AMP,
70337076
ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
70347077
ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
70357078
ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
@@ -8396,6 +8439,12 @@ static const struct hda_fixup alc269_fixups[] = {
83968439
.type = HDA_FIXUP_FUNC,
83978440
.v.func = alc236_fixup_hp_mute_led_micmute_vref,
83988441
},
8442+
[ALC298_FIXUP_SAMSUNG_AMP] = {
8443+
.type = HDA_FIXUP_FUNC,
8444+
.v.func = alc298_fixup_samsung_amp,
8445+
.chained = true,
8446+
.chain_id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET
8447+
},
83998448
[ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
84008449
.type = HDA_FIXUP_VERBS,
84018450
.v.verbs = (const struct hda_verb[]) {
@@ -9342,13 +9391,13 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
93429391
SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
93439392
SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
93449393
SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
9345-
SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9346-
SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9347-
SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9348-
SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9394+
SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
9395+
SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_AMP),
9396+
SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_AMP),
9397+
SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_AMP),
93499398
SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
9350-
SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9351-
SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
9399+
SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_AMP),
9400+
SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_AMP),
93529401
SND_PCI_QUIRK(0x144d, 0xc832, "Samsung Galaxy Book Flex Alpha (NP730QCJ)", ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
93539402
SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
93549403
SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
@@ -9716,7 +9765,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
97169765
{.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
97179766
{.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
97189767
{.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
9719-
{.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"},
9768+
{.id = ALC298_FIXUP_SAMSUNG_AMP, .name = "alc298-samsung-amp"},
97209769
{.id = ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc256-samsung-headphone"},
97219770
{.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
97229771
{.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},

0 commit comments

Comments
 (0)