mbp-2016-linux icon indicating copy to clipboard operation
mbp-2016-linux copied to clipboard

MacBook Pro 15+: Audio Support

Open aunali1 opened this issue 4 years ago • 19 comments

Discussion and updates regarding Apple Audio related support. Parent thread is #71.

aunali1 avatar Aug 06 '19 16:08 aunali1

Small note: I fixed the start audio glitch, audio is mostly fine now.

As I stated before, the config has to be written if we want both speaker and headphones to work, and I have no 20 hours to waste. If anyone else is willing to spend the time trying to understand that format, I'd gladly appreciate it.

MCMrARM avatar Aug 19 '19 16:08 MCMrARM

Ok I wrote a config:

<confdir:pcm/front.conf>
<confdir:pcm/surround40.conf>

AppleT2.pcm.surround40.0 {
	@args [ CARD ]
	@args.CARD {
		type string
	}
	type hw
	card $CARD
	device 1
}
AppleT2.pcm.front.0 {
	@args [ CARD ]
	@args.CARD {
		type string
	}
	type hw
	card $CARD
	device 0
}

Put this in /usr/share/alsa/cards/AppleT2.conf No idea if this can be written in a better way or not, for now this is what we're stuck with.

MCMrARM avatar Aug 19 '19 17:08 MCMrARM

I can confirm that with ALSA config file mentioned above there are now two configurations in sound settings:

  • Analog Surround 4.0 Output - speakers
  • Analog Stereo Output - headphone jack and one output device. Microphone is still not available and audio output configuration are not dynamically changed (dis/connecting headphones). Nevertheless really good job @MCMrARM!

In the mean time could you please check wifi thread - #112

I'm pretty sure noone (besides you) was able to make wifi working. Maybe we are missing something. Cheers everyone!

mikeeq avatar Aug 19 '19 19:08 mikeeq

@MCMrARM to make internal mic working do we need to only modify existing ALSA config file or does it need any work on driver side to be done?

mikeeq avatar Aug 28 '19 10:08 mikeeq

Work on the driver needs to be done.

MCMrARM avatar Aug 28 '19 11:08 MCMrARM

Implemented jack detection: https://github.com/MCMrARM/mbp2018-bridge-drv/commit/d3224b861177ed863c492833d17e09c02ed1d53f No idea how to integrate into alsa ¯\_(ツ)_/¯

MCMrARM avatar Aug 28 '19 19:08 MCMrARM

I'll try to get the microphone working tomorrow, no promises though.

MCMrARM avatar Aug 28 '19 19:08 MCMrARM

Some good news: I got internal mic working at all, will push code today. Not sure how good are the results. The microphone is apparently a triple-channel device btw. Might be a little bit of a mess to get it working in alsa.

edit: will do it tomorrow, as I had issues with glitches and had to do some hacks.

MCMrARM avatar Aug 29 '19 19:08 MCMrARM

Ok, this took a while to figure out but I got the mic/external audio input working under Pulse. https://gist.github.com/MCMrARM/c357291e4e5c18894bea10665dcebffb <- required files Note that the new commits broke the old audio config, and you MUST switch to the new configuration if you update. Though the mic works now, so nice.

MCMrARM avatar Aug 30 '19 19:08 MCMrARM

@MCMrARM are there any additional steps needed? I copied those 3 config files, recompiled module, loaded it and there's no audio/input device now - only dummy output.

Update: My bad i didn't execute dracut to update initramfs... ehh. So after a reboot there are two output devices with two configurations each (as it is in pulseaudio config file from link above) but any input device is not recognized ;). I was trying to modify that pulseaudio config file and maybe we need to change paths-output to paths-input in mappings for mics ;)

mikeeq avatar Aug 30 '19 19:08 mikeeq

@mikeeq I mean, I don't know, it works for me. Does changing the paths-output to paths-input work for you?

MCMrARM avatar Sep 01 '19 09:09 MCMrARM

@aunali1 @ppaulweber @jhohisel Has anyone of you guys tried to use new audio driver and is microphone working for you? For me, after changing to paths-input microphones are visible in sound settings but they are not working.

mikeeq avatar Sep 03 '19 16:09 mikeeq

With the driver from latest git and the config files linked above, launching pulseaudio fails on my MBP15,2 with:

Apr 08 19:00:58 little kernel: aaudio_pcm_open
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_params
Apr 08 19:00:58 little kernel: aaudio_pcm_open
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_params
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_free
Apr 08 19:00:58 little kernel: aaudio_pcm_close
Apr 08 19:00:58 little kernel: aaudio_pcm_open
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_params
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_free
Apr 08 19:00:58 little kernel: aaudio_pcm_close
Apr 08 19:00:58 little kernel: aaudio_pcm_open
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_params
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_free
Apr 08 19:00:58 little kernel: aaudio_pcm_close
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_free
Apr 08 19:00:58 little kernel: aaudio_pcm_close
Apr 08 19:00:58 little kernel: aaudio_pcm_open
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_params
Apr 08 19:00:58 little kernel: aaudio_pcm_trigger 1
Apr 08 19:00:58 little kernel: aaudio: Backed up the buffer in 72794953ns [16640]
Apr 08 19:00:58 little kernel: aaudio aaudio: Received timestamp update for dev=3a ts=480cfd953e seed=0
Apr 08 19:00:58 little kernel: aaudio: Started the audio device in 97586739ns
Apr 08 19:00:58 little kernel: aaudio_pcm_open
Apr 08 19:00:58 little kernel: aaudio_pcm_hw_params
Apr 08 19:00:58 little kernel: x86/PAT: pulseaudio:1681 map pfn RAM range req uncached-minus for [mem 0x7c440000-0x7c470fff], got write-back
Apr 08 19:00:58 little kernel: aaudio_pcm_trigger 1
Apr 08 19:00:58 little kernel: aaudio: Started the audio device in 3235965ns
Apr 08 19:00:58 little kernel: aaudio_pcm_pointer while not started
Apr 08 19:00:58 little kernel: aaudio aaudio: Received timestamp update for dev=21 ts=4810dd812a seed=0
Apr 08 19:00:59 little systemd[748]: Started Sound Service.
Apr 08 19:00:59 little kernel: aaudio aaudio: Received timestamp update for dev=3a ts=4821a726d0 seed=0
Apr 08 19:00:59 little kernel: aaudio aaudio: Received timestamp update for dev=21 ts=48258774df seed=0
Apr 08 19:00:59 little kernel: aaudio aaudio: Received timestamp update for dev=3a ts=4836508bf2 seed=0
Apr 08 19:00:59 little kernel: aaudio_pcm_trigger 0
Apr 08 19:00:59 little kernel: aaudio_pcm_hw_free
Apr 08 19:00:59 little kernel: aaudio_pcm_close
Apr 08 19:00:59 little kernel: aaudio_pcm_trigger 0
Apr 08 19:00:59 little kernel: aaudio_pcm_hw_free
Apr 08 19:00:59 little kernel: aaudio_pcm_close
Apr 08 19:00:59 little systemd[748]: pulseaudio.service: Main process exited, code=killed, status=9/KILL

jbg avatar Apr 08 '20 12:04 jbg

Disabling realtime scheduling in pulseaudio fixes the above. It appears that with this driver, pulseaudio spends too much time in realtime blocks and gets killed.

jbg avatar Apr 08 '20 12:04 jbg

Hi guys, you're doing a great job @MCMrARM ! I have a quick question, I'm running Ubuntu on a MacbookPro 2017 (no T2 chip), would this approach work for me? Can i try https://github.com/MCMrARM/mbp2018-bridge-drv ? Thanks!

cristianmiranda avatar Apr 20 '20 20:04 cristianmiranda

Have you tried this repo yet? https://github.com/MCMrARM/mbp2018-bridge-drv

I would just add add an install command to that Makefile ie

obj-m += bce.o
bce-objs := pci.o mailbox.o queue.o queue_dma.o vhci/vhci.o vhci/queue.o vhci/transfer.o audio/audio.o audio/protocol.o audio/protocol_bce.o audio/pcm.o

MY_CFLAGS += -DWITHOUT_NVME_PATCH
#MY_CFLAGS += -g -DDEBUG
ccflags-y += ${MY_CFLAGS}
CC += ${MY_CFLAGS}

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

install:
        mkdir -p /lib/modules/$(shell uname -r)/updates
        cp bce.ko /lib/modules/$(shell uname -r)/updates
        depmod -a

**the lines under all: clean: and install: need to be indented with a tab then just run, make + make install + reboot Give that a shot and see if it works.

leifliddy avatar Apr 21 '20 02:04 leifliddy

Hey, thanks! I haven't installed linux on my T2 macbook, but if I decide to do it I'll definitely check this out. Thanks again!

cristianmiranda avatar Apr 29 '20 17:04 cristianmiranda

@leifliddy it doesnt work why im a simple man who uses 15,4 mac and wants sound in arch llinux

00:1f.3 Audio device: Intel Corporation Cannon Point-LP High Definition Audio Controller (rev 30)
        Subsystem: Intel Corporation Device 7270
        Flags: bus master, fast devsel, latency 64, IRQ 55
        Memory at 91a10000 (64-bit, non-prefetchable) [size=16K]
        Memory at 4000000000 (64-bit, non-prefetchable) [size=1M]
        Capabilities: <access denied>
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel, snd_soc_skl, snd_sof_pci
--
02:00.3 Multimedia audio controller: Apple Inc. Apple Audio Device (rev 01)
        Subsystem: Apple Inc. Device 1885
        Flags: fast devsel
        Memory at b0c00000 (64-bit, prefetchable) [disabled] [size=4M]
        Memory at b1180000 (64-bit, prefetchable) [disabled] [size=512K]
        Memory at b1230000 (64-bit, prefetchable) [disabled] [size=64K]
        Capabilities: <access denied>

mushoku-ningen avatar Jul 30 '20 03:07 mushoku-ningen

@leifliddy my problem solved you should add mkinitcpio -p linux at the end

mushoku-ningen avatar Jul 30 '20 14:07 mushoku-ningen