Skip to content

Commit b5bf0a9

Browse files
BWhittentiwai
authored andcommitted
ALSA: hda - Add fixup for MacBook Air 6,1 and 6,2 with CS4208 codec
This patch adds the default pin configuration and some init verbs for setting COEFs, in addition to the correction of input pin AMP caps for MacBook Air 6,1 and 6,2. With these changes, the headphone jack detection starts working properly. [trivial space fixes by tiwai] Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=60811 Signed-off-by: Ben Whitten <benwhitten@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent f82d7d1 commit b5bf0a9

1 file changed

Lines changed: 67 additions & 5 deletions

File tree

‎sound/pci/hda/patch_cirrus.c‎

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ enum {
111111
/* 0x0009 - 0x0014 -> 12 test regs */
112112
/* 0x0015 - visibility reg */
113113

114+
/* Cirrus Logic CS4208 */
115+
#define CS4208_VENDOR_NID 0x24
116+
114117
/*
115118
* Cirrus Logic CS4210
116119
*
@@ -223,6 +226,16 @@ static const struct hda_verb cs_coef_init_verbs[] = {
223226
{} /* terminator */
224227
};
225228

229+
static const struct hda_verb cs4208_coef_init_verbs[] = {
230+
{0x01, AC_VERB_SET_POWER_STATE, 0x00}, /* AFG: D0 */
231+
{0x24, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */
232+
{0x24, AC_VERB_SET_COEF_INDEX, 0x0033},
233+
{0x24, AC_VERB_SET_PROC_COEF, 0x0001}, /* A1 ICS */
234+
{0x24, AC_VERB_SET_COEF_INDEX, 0x0034},
235+
{0x24, AC_VERB_SET_PROC_COEF, 0x1C01}, /* A1 Enable, A Thresh = 300mV */
236+
{} /* terminator */
237+
};
238+
226239
/* Errata: CS4207 rev C0/C1/C2 Silicon
227240
*
228241
* http://www.cirrus.com/en/pubs/errata/ER880C3.pdf
@@ -295,6 +308,8 @@ static int cs_init(struct hda_codec *codec)
295308
/* init_verb sequence for C0/C1/C2 errata*/
296309
snd_hda_sequence_write(codec, cs_errata_init_verbs);
297310
snd_hda_sequence_write(codec, cs_coef_init_verbs);
311+
} else if (spec->vendor_nid == CS4208_VENDOR_NID) {
312+
snd_hda_sequence_write(codec, cs4208_coef_init_verbs);
298313
}
299314

300315
snd_hda_gen_init(codec);
@@ -434,6 +449,29 @@ static const struct hda_pintbl mba42_pincfgs[] = {
434449
{} /* terminator */
435450
};
436451

452+
static const struct hda_pintbl mba6_pincfgs[] = {
453+
{ 0x10, 0x032120f0 }, /* HP */
454+
{ 0x11, 0x500000f0 },
455+
{ 0x12, 0x90100010 }, /* Speaker */
456+
{ 0x13, 0x500000f0 },
457+
{ 0x14, 0x500000f0 },
458+
{ 0x15, 0x770000f0 },
459+
{ 0x16, 0x770000f0 },
460+
{ 0x17, 0x430000f0 },
461+
{ 0x18, 0x43ab9030 }, /* Mic */
462+
{ 0x19, 0x770000f0 },
463+
{ 0x1a, 0x770000f0 },
464+
{ 0x1b, 0x770000f0 },
465+
{ 0x1c, 0x90a00090 },
466+
{ 0x1d, 0x500000f0 },
467+
{ 0x1e, 0x500000f0 },
468+
{ 0x1f, 0x500000f0 },
469+
{ 0x20, 0x500000f0 },
470+
{ 0x21, 0x430000f0 },
471+
{ 0x22, 0x430000f0 },
472+
{} /* terminator */
473+
};
474+
437475
static void cs420x_fixup_gpio_13(struct hda_codec *codec,
438476
const struct hda_fixup *fix, int action)
439477
{
@@ -556,22 +594,23 @@ static int patch_cs420x(struct hda_codec *codec)
556594

557595
/*
558596
* CS4208 support:
559-
* Its layout is no longer compatible with CS4206/CS4207, and the generic
560-
* parser seems working fairly well, except for trivial fixups.
597+
* Its layout is no longer compatible with CS4206/CS4207
561598
*/
562599
enum {
600+
CS4208_MBA6,
563601
CS4208_GPIO0,
564602
};
565603

566604
static const struct hda_model_fixup cs4208_models[] = {
567605
{ .id = CS4208_GPIO0, .name = "gpio0" },
606+
{ .id = CS4208_MBA6, .name = "mba6" },
568607
{}
569608
};
570609

571610
static const struct snd_pci_quirk cs4208_fixup_tbl[] = {
572611
/* codec SSID */
573-
SND_PCI_QUIRK(0x106b, 0x7100, "MacBookPro 6,1", CS4208_GPIO0),
574-
SND_PCI_QUIRK(0x106b, 0x7200, "MacBookPro 6,2", CS4208_GPIO0),
612+
SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6),
613+
SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6),
575614
{} /* terminator */
576615
};
577616

@@ -588,18 +627,35 @@ static void cs4208_fixup_gpio0(struct hda_codec *codec,
588627
}
589628

590629
static const struct hda_fixup cs4208_fixups[] = {
630+
[CS4208_MBA6] = {
631+
.type = HDA_FIXUP_PINS,
632+
.v.pins = mba6_pincfgs,
633+
.chained = true,
634+
.chain_id = CS4208_GPIO0,
635+
},
591636
[CS4208_GPIO0] = {
592637
.type = HDA_FIXUP_FUNC,
593638
.v.func = cs4208_fixup_gpio0,
594639
},
595640
};
596641

642+
/* correct the 0dB offset of input pins */
643+
static void cs4208_fix_amp_caps(struct hda_codec *codec, hda_nid_t adc)
644+
{
645+
unsigned int caps;
646+
647+
caps = query_amp_caps(codec, adc, HDA_INPUT);
648+
caps &= ~(AC_AMPCAP_OFFSET);
649+
caps |= 0x02;
650+
snd_hda_override_amp_caps(codec, adc, HDA_INPUT, caps);
651+
}
652+
597653
static int patch_cs4208(struct hda_codec *codec)
598654
{
599655
struct cs_spec *spec;
600656
int err;
601657

602-
spec = cs_alloc_spec(codec, 0); /* no specific w/a */
658+
spec = cs_alloc_spec(codec, CS4208_VENDOR_NID);
603659
if (!spec)
604660
return -ENOMEM;
605661

@@ -609,6 +665,12 @@ static int patch_cs4208(struct hda_codec *codec)
609665
cs4208_fixups);
610666
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
611667

668+
snd_hda_override_wcaps(codec, 0x18,
669+
get_wcaps(codec, 0x18) | AC_WCAP_STEREO);
670+
cs4208_fix_amp_caps(codec, 0x18);
671+
cs4208_fix_amp_caps(codec, 0x1b);
672+
cs4208_fix_amp_caps(codec, 0x1c);
673+
612674
err = cs_parse_auto_config(codec);
613675
if (err < 0)
614676
goto error;

0 commit comments

Comments
 (0)