Bug 102131

Summary: Macbook 5,2 headphone does not produce sound
Product: Drivers Reporter: Jeffery Miller (jefferym)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: RESOLVED CODE_FIX    
Severity: normal CC: tiwai
Priority: P1    
Hardware: Intel   
OS: Linux   
Kernel Version: 4.0.5.i386 Subsystem:
Regression: No Bisected commit-id:
Attachments: alsa-info output without the headphone plugged in
alsa-info output with the headphone plugged in
Add vref to macbook 5,2 external headphone jack
alsa-info output with the headphones after the patch

Description Jeffery Miller 2015-07-30 16:00:35 UTC
Created attachment 184021 [details]
alsa-info output without the headphone plugged in

Headphones plugged into the external headphone jack do not produce sound. When a headphone is plugged in the main speakers do mute and the headphones show up as connected. Sound is just not produced.
Comment 1 Jeffery Miller 2015-07-30 16:03:22 UTC
Created attachment 184031 [details]
alsa-info output with the headphone plugged in

This is the headphone attached and sound does not work.
Comment 2 Jeffery Miller 2015-07-30 16:05:37 UTC
Created attachment 184041 [details]
Add vref to macbook 5,2 external headphone jack

Attached is a kernel patch to the 4.0.5 kernel adding the needed vref bits to the output jack. This resolves the sound issue.
Comment 3 Jeffery Miller 2015-07-30 16:07:11 UTC
Created attachment 184051 [details]
alsa-info output with the headphones after the patch

This is the alsa-info with the patch applied and the headphone plugged in.
Comment 4 Takashi Iwai 2015-07-30 16:13:44 UTC
Could you check the patch below?

If this doesn't work, try to adjust the pinctl value of NID 0x18 and 0x19 manually via hda-verb, e.g.
  hda-verb /dev/snd/hwC0D0 0x18 SET_PIN_WID 0x21
  hda-verb /dev/snd/hwC0D0 0x18 SET_PIN_WID 0x21

Change from 0x20 to 0x27.
Comment 5 Jeffery Miller 2015-07-30 16:14:22 UTC
My test case was to play some sound using aplay and insert headphones listening for sound.

I was able to use hda-verb commands to enable set the VREF bits on the 0x15 pin. I tested setting VREF_80, VREF_50, VREF_100. They all seemed to produce sound from the headphone slot. VREF_HIZ and VREF_GRD would result in no sound.

I tested that it still worked after a sleep.

I reused the alc889_fixup_mbp_vref function in the patch noticing that it happened to set an appropriate bit on the 0x15 pin. I did not attempt to clean up or reduce any of the other potential quirks.

Is there something else that I should test or try? Is there any other information that would be useful?
Comment 6 Takashi Iwai 2015-07-30 16:18:07 UTC
Ah, I overlooked your patch.  Basically it should work by just replacing ALC889_FIXUP_IMAC91_VREF with ALC889_FIXUP_MBA11_VREF or _MBA21_VREF.

--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2222,7 +2222,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
 	SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
 	SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
-	SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
+	SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
 
 	SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
 	SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
Comment 7 Jeffery Miller 2015-07-30 16:20:38 UTC
I will apply the patch in comment #6 and test it this evening when I have access again to the machine.
Comment 8 Jeffery Miller 2015-07-30 19:47:16 UTC
I have tested the patch and confirm it fixes with the audio output on the headphones. 

Thank You.
Comment 9 Takashi Iwai 2015-07-30 20:35:16 UTC
Good to hear, I queued the fix now.  It'll be included in the next pull request, hopefully merged in 4.2-rc5, and backported later to stable kernels.