Bug 195671

Summary: no sound on macbook pro 2016
Product: Drivers Reporter: Joël Krähemann (jkraehemann)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: NEW ---    
Severity: normal CC: andy.holst, bugs-kernel, christoph.gysin, danielroschka+kernel, david.osguthorpe, hilobakho, hugo, hujq, jan, jirka, jkraehemann, lawrencechou1024+bugzilla, loonkiller, lukas, mcgrof, olli.salo, peteryuchuang, ronald, tiwai, zdanevich.vitaly
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.11.0 Subsystem:
Regression: No Bisected commit-id:
Attachments: alsa-info
add mbp131 model to cirrus codec patch
new alsa-info.txt
hda-verb invocation 0x4
hda-verb invocation 0x9
hda-verb invocation 0x12
hda-verb invocation 0x13
hda-verb invocation 0xC
hda-verb invocation 0xD
hda-verb invocation 0xE
HDA-Analyzer showing pin complex line out input amplifier
alsamixer showing imcomplete amplifiers
setup script hda-verb
hda-tool output
hda jack retask
output generate by start-script to probe for soundcard
start script to reconfigure soundcard
add cs8409 codec to cirrus patch
alsa-info.txt
patch to patch_cirrus.c
alsa-info.txt linux-4.12.4
patch to patch_cirrus.c

Description Joël Krähemann 2017-05-05 10:44:37 UTC
The cirrus logic audio codec does not support the macbook pro 2016 soundcard, yet.
Comment 1 Joël Krähemann 2017-05-05 10:46:06 UTC
Created attachment 256225 [details]
alsa-info
Comment 2 Joël Krähemann 2017-05-05 22:11:59 UTC
Hi 

I tried to patch patch_cirrus.c but didn't help. May be this failure stops the audio driver to do its work.

May 05 23:56:49 localhost kernel: snd_hda_intel 0000:00:1f.3: failed to add i915 component master (-19)
Comment 3 Joël Krähemann 2017-05-05 22:14:08 UTC
Created attachment 256231 [details]
add mbp131 model to cirrus codec patch
Comment 4 Joël Krähemann 2017-05-06 09:59:11 UTC
Created attachment 256239 [details]
new alsa-info.txt

with 4.11.0 and applied patch to output looks different.
Comment 5 Joël Krähemann 2017-05-06 10:17:30 UTC
alsamixer shows only one control for PCM. Here is additionally the output of lspci -vvnn

00:1f.3 Audio device [0403]: Intel Corporation Sunrise Point-LP HD Audio [8086:9d70] (rev 21)
        Subsystem: Intel Corporation Device [8086:7270]
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 64, Cache Line Size: 256 bytes
        Interrupt: pin A routed to IRQ 35
        Region 0: Memory at 92820000 (64-bit, non-prefetchable) [size=16K]
        Region 4: Memory at 90000000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: [50] Power Management version 3
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot+,D3cold+)
                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
                Address: 00000000fee003b8  Data: 0000
        Kernel driver in use: snd_hda_intel
Comment 6 Takashi Iwai 2017-05-06 10:20:44 UTC
The codec chip is unknown, so the driver applied the generic method, thus passing model option doesn't work at all since the model option is specific to the codec drivers.

For most of Macs, the required quirks are to reprogram the default pin configurations and to turn on the GPIO pins.  You can do both of them dynamically and via "patch" firmware.

Let's begin with GPIO.  You can turn each GPIO pin on/off like:
  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK 0x01
  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DIR 0x01
  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0x01

This is for the first GPIO (bit 0).  For GPIO2, use bit 1, i.e. replace 0x01 with 0x02.  For GPIO3, replace it with 0x04.  And so on.  You have up to 8 GPIO pins.
Some of them might control the amplifier for the headphone and the speaker, according to the past experience with Apple devices.

Also, you should check the detectable pins, e.g. use hdajackretask.  BIOS often give the incorrect default pin configuration, and you may have to reprogram by yourself.

Once when you figure out the setup, it can be put in "patch" firmware file.  See Documentation/sound/hd-audio/notes.rst "Early Patching" section.

The remaining issue, the i915 error, is strange, though.  It means that you have no Intel graphics on your machine, or i915 driver isn't used, or i915 driver isn't loaded properly before HD-audio.  But this error shouldn't affect to the analog I/O.
Comment 7 Takashi Iwai 2017-05-06 10:21:33 UTC
(In reply to Joël Krähemann from comment #5)
> alsamixer shows only one control for PCM.

It's because you're running PulseAudio and alsa-lib pulse plugin.  Run alsamixer with -c0 option.
Comment 8 Joël Krähemann 2017-05-06 14:33:34 UTC
No I don't have any pulseaudio. I do linuxfromscratch.org
Comment 9 Joël Krähemann 2017-05-06 14:57:01 UTC
bash-4.4# amixer controls
numid=15,iface=CARD,name='HDMI/DP,pcm=3 Jack'
numid=53,iface=CARD,name='Headphone Phantom Jack'
numid=49,iface=CARD,name='Internal Mic Phantom Jack'
numid=50,iface=CARD,name='Mic Phantom Jack'
numid=51,iface=CARD,name='Speaker Front Phantom Jack'
numid=52,iface=CARD,name='Speaker Surround Phantom Jack'
numid=34,iface=MIXER,name='PCM Playback Volume'
numid=16,iface=MIXER,name='IEC958 Playback Con Mask'
numid=21,iface=MIXER,name='IEC958 Playback Con Mask',index=1
numid=26,iface=MIXER,name='IEC958 Playback Con Mask',index=2
numid=17,iface=MIXER,name='IEC958 Playback Pro Mask'
numid=22,iface=MIXER,name='IEC958 Playback Pro Mask',index=1
numid=27,iface=MIXER,name='IEC958 Playback Pro Mask',index=2
numid=18,iface=MIXER,name='IEC958 Playback Default'
numid=23,iface=MIXER,name='IEC958 Playback Default',index=1
numid=28,iface=MIXER,name='IEC958 Playback Default',index=2
numid=19,iface=MIXER,name='IEC958 Playback Switch'
numid=24,iface=MIXER,name='IEC958 Playback Switch',index=1
numid=29,iface=MIXER,name='IEC958 Playback Switch',index=2
numid=55,iface=PCM,name='Capture Channel Map'
numid=54,iface=PCM,name='Playback Channel Map'
numid=56,iface=PCM,name='Capture Channel Map',device=2
numid=57,iface=PCM,name='Capture Channel Map',index=1,device=2
numid=58,iface=PCM,name='Capture Channel Map',index=2,device=2
numid=59,iface=PCM,name='Capture Channel Map',index=3,device=2
numid=60,iface=PCM,name='Capture Channel Map',index=4,device=2
numid=61,iface=PCM,name='Capture Channel Map',index=5,device=2
numid=62,iface=PCM,name='Capture Channel Map',index=6,device=2
numid=20,iface=PCM,name='ELD',device=3
numid=31,iface=PCM,name='Playback Channel Map',device=3
numid=25,iface=PCM,name='ELD',device=7
numid=32,iface=PCM,name='Playback Channel Map',device=7
numid=30,iface=PCM,name='ELD',device=8
numid=33,iface=PCM,name='Playback Channel Map',device=8
Comment 10 Joël Krähemann 2017-05-06 15:01:59 UTC
bash-4.4# aplay -L 
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=PCH
    HDA Intel PCH, Generic Analog
    Default Audio Device
sysdefault:CARD=PCH
    HDA Intel PCH, Generic Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, Generic Analog
    Front speakers
surround21:CARD=PCH,DEV=0
    HDA Intel PCH, Generic Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, Generic Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, Generic Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, Generic Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, Generic Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, Generic Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=PCH,DEV=0
    HDA Intel PCH, HDMI 0
    HDMI Audio Output
hdmi:CARD=PCH,DEV=1
    HDA Intel PCH, HDMI 1
    HDMI Audio Output
hdmi:CARD=PCH,DEV=2
    HDA Intel PCH, HDMI 2
    HDMI Audio Output
Comment 11 Joël Krähemann 2017-05-06 15:09:12 UTC
bash-4.4# hdajacksensetest -a
Pin 0x24 (Internal Speaker): present = No
Pin 0x25 (Internal Speaker): present = No
Pin 0x26 (Not connected): present = No
Pin 0x27 (Not connected): present = No
Pin 0x28 (Not connected): present = No
Pin 0x29 (Not connected): present = No
Pin 0x2a (Not connected): present = No
Pin 0x2b (Not connected): present = No
Pin 0x2c (Green Headphone): present = No
Pin 0x2d (Not connected): present = No
Pin 0x2e (Not connected): present = No
Pin 0x2f (Not connected): present = No
Pin 0x30 (Not connected): present = No
Pin 0x31 (Not connected): present = No
Pin 0x32 (Not connected): present = No
Pin 0x33 (Not connected): present = No
Pin 0x34 (Not connected): present = No
Pin 0x35 (Not connected): present = No
Pin 0x36 (Not connected): present = No
Pin 0x37 (Not connected): present = No
Pin 0x38 (Not connected): present = No
Pin 0x39 (Not connected): present = No
Pin 0x3a (Not connected): present = No
Pin 0x3b (Not connected): present = No
Pin 0x3c (Pink Mic): present = No
Pin 0x3d (Not connected): present = No
Pin 0x3e (Not connected): present = No
Pin 0x3f (Not connected): present = No
Pin 0x40 (Not connected): present = No
Pin 0x41 (Not connected): present = No
Pin 0x42 (Not connected): present = No
Comment 12 Joël Krähemann 2017-05-06 18:38:32 UTC
Hi

I just removed fixup entry of the patched driver. I try to do my own fix-ups, now. I figured out that the IMAC27 had a similar soundcard:

Intel Corporation Sunrise Point-LP HD Audio

That's why I tried its fix-ups.

Joël
Comment 13 Joël Krähemann 2017-05-06 18:47:19 UTC
Hi

I have got this video card

00:02.0 VGA compatible controller [0300]: Intel Corporation Iris Graphics 540 [8086:1926] (rev 0a) (prog-if 00 [VGA controller])
        Subsystem: Apple Inc. Device [106b:0150]
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 256 bytes
        Interrupt: pin A routed to IRQ 255
        Region 0: Memory at 91000000 (64-bit, non-prefetchable) [size=16M]
        Region 2: Memory at b0000000 (64-bit, prefetchable) [size=256M]
        Region 4: I/O ports at 3000 [size=64]
        [virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
        Capabilities: [40] Vendor Specific Information: Len=0c <?>
        Capabilities: [70] Express (v2) Root Complex Integrated Endpoint, MSI 00
                DevCap: MaxPayload 128 bytes, PhantFunc 0
                        ExtTag- RBE+
                DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
                        RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop-
                        MaxPayload 128 bytes, MaxReadReq 128 bytes
                DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
                DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR-, OBFF Not Supported
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
        Capabilities: [ac] MSI: Enable- Count=1/1 Maskable- 64bit-
                Address: 00000000  Data: 0000
        Capabilities: [d0] Power Management version 2
                Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [100 v1] Process Address Space ID (PASID)
                PASIDCap: Exec+ Priv-, Max PASID Width: 14
                PASIDCtl: Enable- Exec- Priv-
        Capabilities: [200 v1] Address Translation Service (ATS)
                ATSCap: Invalidate Queue Depth: 00
                ATSCtl: Enable-, Smallest Translation Unit: 00
        Capabilities: [300 v1] Page Request Interface (PRI)
                PRICtl: Enable- Reset-
                PRISta: RF- UPRGI- Stopped-
                Page Request Capacity: 00008000, Page Request Allocation: 00000000
Comment 14 Joël Krähemann 2017-05-06 21:40:44 UTC
Hi

Since I am newbie I have a need for docs like:

http://wiki.osdev.org/Intel_High_Definition_Audio

I just run the following and provide you the output.

bash-4.4# for((i=0;i<$((16#50));i++));do hda-verb /dev/snd/hwC0D0 0x$(printf '%x' $i) 0x0F00 0x9; done &> test-\[0x0-0x50\]-0xf00-0x9.txt
bash-4.4# for((i=0;i<$((16#50));i++));do hda-verb /dev/snd/hwC0D0 0x$(printf '%x' $i) 0x0F00 0x4; done &> test-\[0x0-0x50\]-0xf00-0x4.txt
bash-4.4# for((i=0;i<$((16#50));i++));do hda-verb /dev/snd/hwC0D0 0x$(printf '%x' $i) 0x0F00 0xC; done &> test-\[0x0-0x50\]-0xf00-0xC.txt
bash-4.4# for((i=0;i<$((16#50));i++));do hda-verb /dev/snd/hwC0D0 0x$(printf '%x' $i) 0x0F00 0xD; done &> test-\[0x0-0x50\]-0xf00-0xD.txt
bash-4.4# for((i=0;i<$((16#50));i++));do hda-verb /dev/snd/hwC0D0 0x$(printf '%x' $i) 0x0F00 0x12; done &> test-\[0x0-0x50\]-0xf00-0x12.txt
bash-4.4# for((i=0;i<$((16#50));i++));do hda-verb /dev/snd/hwC0D0 0x$(printf '%x' $i) 0x0F00 0xE; done &> test-\[0x0-0x50\]-0xf00-0xE.txt
bash-4.4# for((i=0;i<$((16#50));i++));do hda-verb /dev/snd/hwC0D0 0x$(printf '%x' $i) 0x0F00 0x13; done &> test-\[0x0-0x50\]-0xf00-0x13.txt


by Joël
Comment 15 Joël Krähemann 2017-05-06 21:42:24 UTC
Created attachment 256245 [details]
hda-verb invocation 0x4
Comment 16 Joël Krähemann 2017-05-06 21:42:59 UTC
Created attachment 256247 [details]
hda-verb invocation 0x9
Comment 17 Joël Krähemann 2017-05-06 21:44:15 UTC
Created attachment 256249 [details]
hda-verb invocation 0x12
Comment 18 Joël Krähemann 2017-05-06 21:44:39 UTC
Created attachment 256251 [details]
hda-verb invocation 0x13
Comment 19 Joël Krähemann 2017-05-06 21:45:17 UTC
Created attachment 256253 [details]
hda-verb invocation 0xC
Comment 20 Joël Krähemann 2017-05-06 21:45:48 UTC
Created attachment 256255 [details]
hda-verb invocation 0xD
Comment 21 Joël Krähemann 2017-05-06 21:46:19 UTC
Created attachment 256257 [details]
hda-verb invocation 0xE
Comment 22 Joël Krähemann 2017-05-06 22:59:06 UTC
Created attachment 256259 [details]
HDA-Analyzer showing pin complex line out input amplifier
Comment 23 Joël Krähemann 2017-05-06 22:59:52 UTC
Created attachment 256261 [details]
alsamixer showing imcomplete amplifiers
Comment 24 Joël Krähemann 2017-05-07 01:39:03 UTC
Hi

HDA-Analyzer shows me a second codec on card0

bash-4.4# hda-verb /dev/snd/hwC0D2 0x2 0x0f00 AMP_OUT_CAP
nid = 0x2, verb = 0xf00, param = 0x12
value = 0x0
bash-4.4# hda-verb /dev/snd/hwC0D2 0x3 0x0f00 AMP_OUT_CAP
nid = 0x3, verb = 0xf00, param = 0x12
value = 0x80000000
Comment 25 Joël Krähemann 2017-05-07 02:59:30 UTC
Created attachment 256263 [details]
setup script hda-verb

I had no success to get a working configuration.
Comment 26 Joël Krähemann 2017-05-07 15:57:30 UTC
Hi

I just take it for serious and started doing a shell script to explore hda-verb.

https://github.com/joelkraehemann/hda-tool
Comment 27 Joël Krähemann 2017-05-07 23:03:25 UTC
Created attachment 256277 [details]
hda-tool output

self-written experimental tool using hda-verb output:

https://github.com/joelkraehemann/hda-tool/blob/master/hda-tool.sh
Comment 28 Joël Krähemann 2017-05-08 14:07:37 UTC
I just try to remove AZX_DCAPS_I915_POWERWELL of AZX_DCAPS_INTEL_SKYLAKE. I just wonder what happens.

At my opinion it makes just no sense that there are no volume controls are available.
Comment 29 Joël Krähemann 2017-05-08 15:19:30 UTC
Hi

just reading the docs about volume knob. May be it helps. The volume knob can be controlled by software.

NID=71
return f002c1
* audio output
* volume knob widget
* beep generator
Comment 30 Joël Krähemann 2017-05-09 12:43:55 UTC
Created attachment 256321 [details]
hda jack retask

Currently I try the following verbs. What would you recommend?
Comment 31 Joël Krähemann 2017-05-09 15:02:32 UTC
Hi

May be helps, as trying different things: I suddenly got:

[   18.942470] snd_hda_codec_generic hdaudioC0D0: autoconfig for Generic: line_outs=2 (0x2f/0x2c/0x0/0x0/0x0) type:hp
[   18.944829] snd_hda_codec_generic hdaudioC0D0:    speaker_outs=2 (0x2b/0x2a/0x0/0x0/0x0)
[   18.947046] snd_hda_codec_generic hdaudioC0D0:    hp_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   18.949184] snd_hda_codec_generic hdaudioC0D0:    mono: mono_out=0x0
[   18.951368] snd_hda_codec_generic hdaudioC0D0:    inputs:
[   18.953643] snd_hda_codec_generic hdaudioC0D0:      Internal Mic=0x44
[   18.955874] snd_hda_codec_generic hdaudioC0D0:      Internal Mic=0x42
[   18.957993] snd_hda_codec_generic hdaudioC0D0:      Mic=0x41
[   18.960143] snd_hda_codec_generic hdaudioC0D0:      Mic=0x3c


with this configuration:

[codec]
0x10138409 0x106b3300 0

[pincfg]
0x24 0x400000f0
0x25 0x400000f0
0x2a 0x91170010
0x2b 0x91170010
0x2f 0x002b4020
0x41 0x00ab9030
0x42 0xa0a60100

[verb]
0x01 0x705 0x00
0x01 0x716 0xff
0x01 0x717 0xff
0x01 0x718 0xff
0x24 0x71c 0x0
0x24 0x71d 0x0
0x24 0x71e 0x0
0x24 0x71f 0x0
0x25 0x71c 0x0
0x25 0x71d 0x0
0x25 0x71e 0x0
0x25 0x71f 0x0
0x2a 0x703 0x1
0x2a 0x500 0x03
0x2a 0x400 0x1440
0x2a 0x71c 0x10
0x2a 0x71d 0x0
0x2a 0x71e 0x17
0x2a 0x71f 0x91
0x2b 0x703 0x1
0x2b 0x500 0x03
0x2b 0x400 0x1440
0x2b 0x71c 0x10
0x2b 0x71d 0x0
0x2b 0x71e 0x17
0x2b 0x71f 0x91
Comment 32 Joël Krähemann 2017-05-09 15:36:31 UTC
Hi

somehow inverse case with head-phones and speakers:

[   18.728526] snd_hda_codec_generic hdaudioC0D0: autoconfig for Generic: line_outs=2 (0x2f/0x30/0x0/0x0/0x0) type:speaker
[   18.731375] snd_hda_codec_generic hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   18.734051] snd_hda_codec_generic hdaudioC0D0:    hp_outs=1 (0x2c/0x0/0x0/0x0/0x0)
[   18.735646] (NULL device *): hwmon_device_register() is deprecated. Please convert the driver to use hwmon_device_register_with_info().
[   18.735686] ACPI: Smart Battery System [SBS0]: Battery Slot [BAT0] (battery present)
[   18.742873] snd_hda_codec_generic hdaudioC0D0:    mono: mono_out=0x0
[   18.746234] snd_hda_codec_generic hdaudioC0D0:    inputs:
[   18.749585] snd_hda_codec_generic hdaudioC0D0:      Internal Mic=0x44
[   18.752401] snd_hda_codec_generic hdaudioC0D0:      Internal Mic=0x42
[   18.754832] snd_hda_codec_generic hdaudioC0D0:      Mic=0x41
[   18.757035] snd_hda_codec_generic hdaudioC0D0:      Mic=0x3c

with this configuration:

[codec]
0x10138409 0x106b3300 0

[pincfg]
0x24 0x400000f0
0x25 0x400000f0
0x2c 0x002b4020
0x2f 0x91170010
0x30 0x91170011
0x41 0x00ab9030
0x42 0xa0a60100

[verb]
0x01 0x705 0x00
0x01 0x716 0xff
0x01 0x717 0xff
0x01 0x718 0xff
0x24 0x71c 0x0
0x24 0x71d 0x0
0x24 0x71e 0x0
0x24 0x71f 0x0
0x25 0x71c 0x0
0x25 0x71d 0x0
0x25 0x71e 0x0
0x25 0x71f 0x0
0x2f 0x703 0x1
0x2f 0x500 0x03
0x2f 0x400 0x1440
0x2f 0x71c 0x10
0x2f 0x71d 0x0
0x2f 0x71e 0x17
0x2f 0x71f 0x91
0x30 0x703 0x1
0x30 0x500 0x03
0x30 0x400 0x1440
0x30 0x71c 0x10
0x30 0x71d 0x0
0x30 0x71e 0x17
0x30 0x71f 0x91
0x2c 0x703 0x1
0x2c 0x500 0x03
0x2c 0x400 0x1440
0x2c 0x71c 0x10
0x2c 0x71f 0x0
Comment 33 Joël Krähemann 2017-05-09 16:41:00 UTC
Hi

I try to configure my card with additional verbs. I think configuration should be:

2a headphone
2b speaker front
2c speaker rear

[   19.113948] snd_hda_codec_generic hdaudioC0D0: autoconfig for Generic: line_outs=2 (0x2b/0x2c/0x0/0x0/0x0) type:speaker
[   19.118777] snd_hda_codec_generic hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   19.122701] snd_hda_codec_generic hdaudioC0D0:    hp_outs=1 (0x2a/0x0/0x0/0x0/0x0)
[   19.126525] snd_hda_codec_generic hdaudioC0D0:    mono: mono_out=0x0
[   19.130408] snd_hda_codec_generic hdaudioC0D0:    inputs:
[   19.134232] snd_hda_codec_generic hdaudioC0D0:      Internal Mic=0x44
[   19.138168] snd_hda_codec_generic hdaudioC0D0:      Internal Mic=0x42
[   19.141990] snd_hda_codec_generic hdaudioC0D0:      Mic=0x41
[   19.144899] snd_hda_codec_generic hdaudioC0D0:      Mic=0x3c
[   19.152068] snd_hda_codec_generic hdaudioC0D2: autoconfig for Generic: line_outs=0 (0x0/0x0/0x0/0x0/0x0) type:line
[   19.154041] snd_hda_codec_generic hdaudioC0D2:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   19.155947] snd_hda_codec_generic hdaudioC0D2:    hp_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   19.157798] snd_hda_codec_generic hdaudioC0D2:    mono: mono_out=0x0
[   19.159433] snd_hda_codec_generic hdaudioC0D2:    dig-out=0x3/0x0
[   19.161078] snd_hda_codec_generic hdaudioC0D2:    inputs:
[   19.163546] input: HDA Intel PCH HDMI as /devices/pci0000:00/0000:00:1f.3/sound/card0/input7

Here is the config:

[codec]
0x10138409 0x106b3300 0

[pincfg]
0x24 0x400000f0
0x25 0x400000f0
0x2a 0x002b4020
0x2b 0x91170010
0x2c 0x91170011
0x41 0x00ab9030
0x42 0xa0a60100

[verb]
0x01 0x705 0x00
0x01 0x716 0xff
0x01 0x717 0xff
0x01 0x718 0xff
0x24 0x71c 0x0
0x24 0x71d 0x0
0x24 0x71e 0x0
0x24 0x71f 0x0
0x25 0x71c 0x0
0x25 0x71d 0x0
0x25 0x71e 0x0
0x25 0x71f 0x0
0x2c 0x71c 0x0
0x2c 0x71d 0x0
0x2c 0x71e 0x0
0x2c 0x71f 0x0
0x2b 0x500 0x03
0x2b 0x400 0x1440
0x2b 0x71c 0x10
0x2b 0x71d 0x0
0x2b 0x71e 0x17
0x2b 0x71f 0x91
0x2c 0x500 0x03
0x2c 0x400 0x1440
0x2c 0x71c 0x10
0x2c 0x71d 0x0
0x2c 0x71e 0x17
0x2c 0x71f 0x91
0x2a 0x500 0x03
0x2a 0x400 0x1440
0x2a 0x71c 0x10
0x2a 0x71d 0x0
0x2a 0x71e 0x17
0x2a 0x71f 0x0
Comment 34 Joël Krähemann 2017-05-09 22:59:05 UTC
Hi

Now I understand better. The codec should be a CS8409.

Joël
Comment 35 Joël Krähemann 2017-05-11 23:06:39 UTC
Created attachment 256401 [details]
output generate by start-script to probe for soundcard

This is the output produced by the start script.
Comment 36 Joël Krähemann 2017-05-11 23:08:44 UTC
Created attachment 256403 [details]
start script to reconfigure soundcard

Since I get always the same output. Could anyone help me to improve it?
Comment 37 Joël Krähemann 2017-05-12 02:20:58 UTC
Created attachment 256477 [details]
add cs8409 codec to cirrus patch
Comment 38 Joël Krähemann 2017-05-13 02:41:50 UTC
Created attachment 256497 [details]
alsa-info.txt
Comment 39 Joël Krähemann 2017-05-13 23:53:09 UTC
Created attachment 256509 [details]
patch to patch_cirrus.c

fixed infinite loop during configuration.
Comment 40 Joël Krähemann 2017-08-06 03:51:39 UTC
Created attachment 257831 [details]
alsa-info.txt linux-4.12.4
Comment 41 Joël Krähemann 2017-09-07 17:46:56 UTC
Created attachment 258253 [details]
patch to patch_cirrus.c

some init verbs found in the net it is of a windows driver's .inf file.
Comment 42 Łukasz Żarnowiecki 2017-09-08 14:32:53 UTC
Is audio working now with this patch?
Comment 43 Joël Krähemann 2017-09-21 09:54:25 UTC
no not at all. Today, I test some additional verbs of the 420x driver.
I think it is used by the emulated 8409 driver, too.
Comment 44 Jirka Kulovany 2017-12-11 16:31:39 UTC
I have tried to check GPIO pins using this little script:

`hda-verb-on.sh:`
```
hda-verb /dev/snd/hwC0D0 $1 SET_GPIO_MASK 0x01
hda-verb /dev/snd/hwC0D0 $1 SET_GPIO_DIR 0x01
hda-verb /dev/snd/hwC0D0 $1 SET_GPIO_DATA 0x01
```

with arguments: 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 without any success.

The last argument 0x80 resulted in 0xffff... value, all others resulted in 0x00 value. I did not hear anything neither from `speaker-test` nor from my browser youtube video.

I have also tried to run `rmmod snd_hda_intel && insmod snd_hda_intel` before every script run to reset all pin settings (without success).

Questions:
- Did I test the GPIOs correctly ?
- What can I try with the `hdajackretask` ? Should I just try random pin assignments and hope for the best?
Comment 45 Joël Krähemann 2017-12-12 18:27:37 UTC
Hi,
I think the HDA codec contains an integrated circuit:

MAX98357BEWL
Comment 46 Luis Chamberlain 2018-08-01 13:32:42 UTC
I see some discussions on patches alsa-devel [0] where this bug was referenced, are these patches for the same bug? What's the status of this bug / effort?

[0] https://www.spinics.net/lists/alsa-devel/msg71179.html
Comment 47 Ronald 2018-12-24 06:17:19 UTC
Over on https://bugzilla.kernel.org/show_bug.cgi?id=110561 some info was posted regarding these MBP's. To summarize what has been there and elsewhere, it seems we have the following chips in play:

MBP13,1:
  Cirrus Logic CS8409     (HDA Codec)
  Cirrus Logic CS42L63A   (Mic+HP ADC/DAC)
  Analog Devices SSM3515  (Speaker Amps)

MBP13,2, MBP13,3:
  Cirrus Logic CS8409     (HDA Codec)
  Cirrus Logic CS42L83A   (Mic+HP ADC/DAC)
  Maxim MAX98706          (Speaker Amps)

In terms of datasheets for these:
  CS8409 - not available, and no good similar has been found either
  CS42L63A/CS42L83A - not available, but CS42L42A appears to be more or less identical; datasheet at https://statics.cirrus.com/pubs/proDatasheet/CS42L42_F4.pdf
  SSM3515 - datasheet at https://www.analog.com/media/en/technical-documentation/data-sheets/SSM3515.pdf
  MAX98706 - not available, but MAX98372 appears to be more or less identical; datasheet at https://datasheets.maximintegrated.com/en/ds/MAX98372.pdf

The various chips are connected via an I²C bus, with the CS8409 acting as the master; GPIO pins 6 and 7 on the CS8409 are SCL and SDA, respectively. The slaves have the following addresses (in hex):
  CS42L42:  90
  SSM3515:  28, 2a, 2c, 2e
  MAX98706: 62, 74, 72, 74

As to interpreting the *I2C command strings David Ulrich found in the Windows 10 registry (see bug 110561 for details), they appear to follow the following format:
  <num-devices>[<slave-address>...]<num-reg-writes>[<register><value>...]

This is to be run as
  foreach slave-address do
    foreach reg-write
      send I²C command sequence: S slave-address-write register value E

For example, "ExitI2C"=hex:04,28,2a,2c,2e,01,00,83 should be executed as the following commands:
  S 28 00 83 E
  S 2a 00 83 E
  S 2c 00 83 E
  S 2d 00 83 E
(writing 83 to register 0 on the SSM3515 powers down and resets the device)

From this we can also see that the "InitI2C", "n0AStreamStartI2C", and "n0AStreamStopI2C" command strings only target the CS42L42, not the amps.

Lastly, the format of the "ExitVerbs" registry entry is as follows: each 4-byte block is a little-endian HDA command verb representation of an HDA verb. For reference (from section 3.7 of the HDA spec): a 32-bit command verb has the format [codec-address(4)][node-id(8)][hda-verb-param(20)], and an hda-verb-param is either 4+16 bits or 12+8 bits.

So the above ExitVerbs are:
 codec nid verb param  (linux verb constant)
     0  01  705    00  (AC_VERB_SET_POWER_STATE)
     0  47    5  0001  (AC_VERB_SET_COEF_INDEX)
     0  47    4  0000  (AC_VERB_SET_PROC_COEF)
     0  47    5  0082  (AC_VERB_SET_COEF_INDEX)
     0  47    4  0000  (AC_VERB_SET_PROC_COEF)
     0  47    5  0003  (AC_VERB_SET_COEF_INDEX)
     0  47    4  8000  (AC_VERB_SET_PROC_COEF)
     0  47    5  0004  (AC_VERB_SET_COEF_INDEX)
     0  47    4  2801  (AC_VERB_SET_PROC_COEF)
     0  47    5  0006  (AC_VERB_SET_COEF_INDEX)
     0  47    4  8000  (AC_VERB_SET_PROC_COEF)
     0  47    5  0007  (AC_VERB_SET_COEF_INDEX)
     0  47    4  2801  (AC_VERB_SET_PROC_COEF)
     0  47    5  0065  (AC_VERB_SET_COEF_INDEX)
     0  47    4  0000  (AC_VERB_SET_PROC_COEF)
     0  47  703    00  (AC_VERB_SET_PROC_STATE)
     0  01  705    03  (AC_VERB_SET_POWER_STATE)
Comment 48 David O 2019-07-08 22:40:41 UTC
I have been able to get audio on my MacBookPro 14,3 essentially replaying a log of the HDA commands sent under OSX.

The 14,3 from what I can see is the same chips as 13,2 and 13,3.

  Cirrus Logic CS8409     (HDA Codec)
  Cirrus Logic CS42L83A   (Mic+HP ADC/DAC)
  Maxim MAX98706          (Speaker Amps)

All setup is done by writing to undocumented coef indexes of the vendor node 0x47.
None of the usual HDA tricks are going to work.
The I2C setup is also coded using writing/reading to coef indexes of the vendor node.

The highly experimental patches are in https://github.com/davidjo/snd_hda_macbookpro.

This is not meant as a working audio system for Linux.
It does play 24 bit (S24_LE), 44.1 kHz 2 or 4 channel audio (this is format programmed by OSX).
There is no volume control.

Curiously I see very little overlap between what OSX sends and the Windows strings in the cs4208_38.inf
file (needed for the 14,3 model) from Bootcamp driver.
Comment 49 Andy Holst 2020-05-17 02:11:35 UTC
On MacBookPro13,3 I can confirm this patch is working as well with built-in audio.
Comment 50 Andy Holst 2020-07-24 21:51:54 UTC
The built-in input/output audio is working for MBP models 13,3 and 14,3 for kernel version 5.5.0+ with the Cirrus 8409 HDA chip driver patch from https://github.com/davidjo/snd_hda_macbookpro, maybe this patch can go into the upstream some time soon if it's stable enough?
Comment 51 B24Bomber 2024-03-17 10:19:07 UTC
This issue still exists in current production

==

BIOS Information
        Vendor: Apple Inc.
        Version: 526.0.0.0.0
        Release Date: 11/15/2023
        ROM Size: 8 MB
        Characteristics:
                PCI is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                Boot from CD is supported
                Selectable boot is supported
                ACPI is supported
                Smart battery is supported
                Function key-initiated network boot is supported
                Targeted content distribution is supported
                UEFI is supported
        BIOS Revision: 0.1

Handle 0x0007, DMI type 1, 27 bytes
System Information
        Manufacturer: Apple Inc.
        Product Name: MacBookPro14,1
        Version: 1.0
        Serial Number: FVFXJ0R6HV2H
        UUID: 48e9ff4b-4b61-59a0-9961-734f9182f60c
        Wake-up Type: Power Switch
        SKU Number:  
        Family: MacBook Pro
Comment 52 B24Bomber 2024-03-17 10:20:52 UTC
See also 

https://bugzilla.kernel.org/show_bug.cgi?id=110561
Comment 53 B24Bomber 2024-03-17 16:41:12 UTC
Hi

We appreciate all the work done for Mac-Pro audio driver.

As noted in :

https://github.com/davidjo/snd_hda_macbookpro/issues/122

This work needs to be included in the base kernel and get out of this out of tree driver activity . You are at risk of producing another abandoned , orphaned driver eventually. It happens all the time.