Skip to content

Commit 9a22a8f

Browse files
KailangYangtiwai
authored andcommitted
ALSA: hda/realtek - Add new codec ALC255/ALC3234 UAJ supported
New codec ALC255/ALC3234 support multifunction jacks. It used for menual select the input device. Signed-off-by: Kailang Yang <kailang@realtek.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 885845d commit 9a22a8f

1 file changed

Lines changed: 97 additions & 7 deletions

File tree

‎sound/pci/hda/patch_realtek.c‎

Lines changed: 97 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,26 +577,35 @@ static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
577577
/*
578578
* COEF access helper functions
579579
*/
580-
static int alc_read_coef_idx(struct hda_codec *codec,
581-
unsigned int coef_idx)
580+
581+
static int alc_read_coefex_idx(struct hda_codec *codec,
582+
hda_nid_t nid,
583+
unsigned int coef_idx)
582584
{
583585
unsigned int val;
584-
snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
586+
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX,
585587
coef_idx);
586-
val = snd_hda_codec_read(codec, 0x20, 0,
588+
val = snd_hda_codec_read(codec, nid, 0,
587589
AC_VERB_GET_PROC_COEF, 0);
588590
return val;
589591
}
590592

591-
static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
593+
#define alc_read_coef_idx(codec, coef_idx) \
594+
alc_read_coefex_idx(codec, 0x20, coef_idx)
595+
596+
static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
597+
unsigned int coef_idx,
592598
unsigned int coef_val)
593599
{
594-
snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
600+
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX,
595601
coef_idx);
596-
snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
602+
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF,
597603
coef_val);
598604
}
599605

606+
#define alc_write_coef_idx(codec, coef_idx, coef_val) \
607+
alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
608+
600609
/* a special bypass for COEF 0; read the cached value at the second time */
601610
static unsigned int alc_get_coef0(struct hda_codec *codec)
602611
{
@@ -3109,6 +3118,19 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
31093118
int val;
31103119

31113120
switch (codec->vendor_id) {
3121+
case 0x10ec0255:
3122+
/* LDO and MISC control */
3123+
alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3124+
/* UAJ function set to menual mode */
3125+
alc_write_coef_idx(codec, 0x45, 0xd089);
3126+
/* Direct Drive HP Amp control(Set to verb control)*/
3127+
val = alc_read_coefex_idx(codec, 0x57, 0x05);
3128+
alc_write_coefex_idx(codec, 0x57, 0x05, val & ~(1<<14));
3129+
/* Set MIC2 Vref gate with HP */
3130+
alc_write_coef_idx(codec, 0x06, 0x6104);
3131+
/* Direct Drive HP Amp control */
3132+
alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6);
3133+
break;
31123134
case 0x10ec0283:
31133135
alc_write_coef_idx(codec, 0x1b, 0x0c0b);
31143136
alc_write_coef_idx(codec, 0x45, 0xc429);
@@ -3140,6 +3162,14 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
31403162
int val;
31413163

31423164
switch (codec->vendor_id) {
3165+
case 0x10ec0255:
3166+
alc_write_coef_idx(codec, 0x45, 0xc489);
3167+
snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3168+
alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6);
3169+
/* Set MIC2 Vref gate to normal */
3170+
alc_write_coef_idx(codec, 0x06, 0x6100);
3171+
snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3172+
break;
31433173
case 0x10ec0283:
31443174
alc_write_coef_idx(codec, 0x45, 0xc429);
31453175
snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
@@ -3171,6 +3201,12 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
31713201
static void alc_headset_mode_default(struct hda_codec *codec)
31723202
{
31733203
switch (codec->vendor_id) {
3204+
case 0x10ec0255:
3205+
alc_write_coef_idx(codec, 0x45, 0xc089);
3206+
alc_write_coef_idx(codec, 0x45, 0xc489);
3207+
alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3208+
alc_write_coef_idx(codec, 0x49, 0x0049);
3209+
break;
31743210
case 0x10ec0283:
31753211
alc_write_coef_idx(codec, 0x06, 0x2100);
31763212
alc_write_coef_idx(codec, 0x32, 0x4ea3);
@@ -3194,6 +3230,12 @@ static void alc_headset_mode_default(struct hda_codec *codec)
31943230
static void alc_headset_mode_ctia(struct hda_codec *codec)
31953231
{
31963232
switch (codec->vendor_id) {
3233+
case 0x10ec0255:
3234+
/* Set to CTIA type */
3235+
alc_write_coef_idx(codec, 0x45, 0xd489);
3236+
alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3237+
alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3238+
break;
31973239
case 0x10ec0283:
31983240
alc_write_coef_idx(codec, 0x45, 0xd429);
31993241
alc_write_coef_idx(codec, 0x1b, 0x0c2b);
@@ -3216,6 +3258,12 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
32163258
static void alc_headset_mode_omtp(struct hda_codec *codec)
32173259
{
32183260
switch (codec->vendor_id) {
3261+
case 0x10ec0255:
3262+
/* Set to OMTP Type */
3263+
alc_write_coef_idx(codec, 0x45, 0xe489);
3264+
alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3265+
alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6);
3266+
break;
32193267
case 0x10ec0283:
32203268
alc_write_coef_idx(codec, 0x45, 0xe429);
32213269
alc_write_coef_idx(codec, 0x1b, 0x0c2b);
@@ -3241,6 +3289,15 @@ static void alc_determine_headset_type(struct hda_codec *codec)
32413289
struct alc_spec *spec = codec->spec;
32423290

32433291
switch (codec->vendor_id) {
3292+
case 0x10ec0255:
3293+
/* combo jack auto switch control(Check type)*/
3294+
alc_write_coef_idx(codec, 0x45, 0xd089);
3295+
/* combo jack auto switch control(Vref conteol) */
3296+
alc_write_coef_idx(codec, 0x49, 0x0149);
3297+
msleep(300);
3298+
val = alc_read_coef_idx(codec, 0x46);
3299+
is_ctia = (val & 0x0070) == 0x0070;
3300+
break;
32443301
case 0x10ec0283:
32453302
alc_write_coef_idx(codec, 0x45, 0xd029);
32463303
msleep(300);
@@ -3387,6 +3444,21 @@ static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
33873444
alc_fixup_headset_mode(codec, fix, action);
33883445
}
33893446

3447+
static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
3448+
const struct hda_fixup *fix, int action)
3449+
{
3450+
if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3451+
/* Set to iphone type */
3452+
alc_write_coef_idx(codec, 0x1b, 0x880b);
3453+
alc_write_coef_idx(codec, 0x45, 0xd089);
3454+
alc_write_coef_idx(codec, 0x1b, 0x080b);
3455+
alc_write_coef_idx(codec, 0x46, 0x0004);
3456+
alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3457+
msleep(30);
3458+
}
3459+
alc_fixup_headset_mode(codec, fix, action);
3460+
}
3461+
33903462
static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
33913463
const struct hda_fixup *fix, int action)
33923464
{
@@ -3688,6 +3760,8 @@ enum {
36883760
ALC283_FIXUP_INT_MIC,
36893761
ALC290_FIXUP_MONO_SPEAKERS,
36903762
ALC269_FIXUP_THINKPAD_ACPI,
3763+
ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
3764+
ALC255_FIXUP_HEADSET_MODE,
36913765
};
36923766

36933767
static const struct hda_fixup alc269_fixups[] = {
@@ -3997,6 +4071,20 @@ static const struct hda_fixup alc269_fixups[] = {
39974071
.chained = true,
39984072
.chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
39994073
},
4074+
[ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
4075+
.type = HDA_FIXUP_PINS,
4076+
.v.pins = (const struct hda_pintbl[]) {
4077+
{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4078+
{ 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
4079+
{ }
4080+
},
4081+
.chained = true,
4082+
.chain_id = ALC255_FIXUP_HEADSET_MODE
4083+
},
4084+
[ALC255_FIXUP_HEADSET_MODE] = {
4085+
.type = HDA_FIXUP_FUNC,
4086+
.v.func = alc_fixup_headset_mode_alc255,
4087+
},
40004088
};
40014089

40024090
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -4039,6 +4127,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
40394127
SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
40404128
SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
40414129
SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS),
4130+
SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4131+
SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
40424132
SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
40434133
SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
40444134
SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),

0 commit comments

Comments
 (0)