davidjo / snd_hda_macbookpro

Kernel audio driver for Macs with 8409 HDA chip + MAX98706/SSM3515 amps
GNU General Public License v2.0
286 stars 61 forks source link

iMac 19.1 sound issue #11

Open aydar-y opened 4 years ago

aydar-y commented 4 years ago

I am trying to make sound work on iMac 19.1. It looks like I have the same sound hardware as most latest MBPs. Everything I tried never worked. Here is the result of inxi -SMA:

System: Host: aydar-iMac Kernel: 5.6.11-050611-generic x86_64 bits: 64 Desktop: Gnome 3.36.1 Distro: Ubuntu 20.04 LTS (Focal Fossa) Machine: Type: Laptop System: Apple product: iMac19,1 v: 1.0 serial: C02ZD2YBJV3N Mobo: Apple model: Mac-AA95B1DDAB278B95 v: iMac19,1 serial: C02936600JNKDMX2S UEFI: Apple v: 1037.100.345.0.0 date: 02/17/2020 Audio: Device-1: Intel Cannon Lake PCH cAVS driver: snd_hda_intel Device-2: AMD Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] driver: snd_hda_intel Sound Server: ALSA v: k5.6.11-050611-generic

mmalek-sa commented 3 years ago

Thanks @davidjo for looking into this, can I get that info in anyway without installing macOS?

davidjo commented 3 years ago

No - the 8409 is an Apple designed chip (altho built by Cirrus) and we have no available documentation - in addition the commands we need are vendor commands which again could do anything and there is no available docs.

If you dont want to mess with your setup you could boot High Sierra on an external disk - see doctordbx items above.

PS I found the details about 18,2 machines online - there is an alsa-info.sh script (alsa-utils package) dump if you google.

rogers06 commented 3 years ago

Thanks for all the work on this issue. I've been trying to get audio to work on my iMac 19,1 for the past couple weeks after a new install of Ubuntu 20.04.1.

The most recent version of patch_imacs.diff.txt from @davidjo above applied and built with no issues. After a reboot, I was able to play system sounds and hear audio on youtube. The mic doesn't seem to be functioning right now, but I haven't dug into that to rule out any other config problems yet.

davidjo commented 3 years ago

Thanks for the update - Ill commit this to the main repo. Have you tried headphones? There is a known issue with mikes on these imacs - the HDA nids associated with the internal mike seems to be swapped on the imacs cf. the macbook pros - I changed the coding but there seems to be something else missing. PS. I am also going to update the amp setup see issue #23 - the current setup is not mapping the speakers correctly.

rogers06 commented 3 years ago

The headphone jack was not functional, unfortunately. In Settings->Sound I selected "Headphones - Built-In Audio" as the output device and got no joy. The sound continued to be routed to the iMac's main speakers. The mic on my earbuds did not work either after switching the input device between "Internal Microphone - Built-In Audio" or "Microphone - Built-In Audio."

Thanks for pointing out the amp issue. I can confirm that the channel mixup happens with this model of iMac, too. I'll take a look at the channel mapping patch soon and post any results over there. I'm currently down a rabbit hole with AMD video drivers failing to install and don't want to confound the two issues.

davidjo commented 3 years ago

Sorry - have you physically tried using headphones - Im still unsure how the Setttings dialog is supposed to interact with the driver. Now that you mention it I think just changing the dialog might not switch the output - as output switching is currently driven by headphone plug events. If you do I would suggest just holding the headphones relatively close to your ears initially - do not put them in just in case.

rogers06 commented 3 years ago

Sorry for being unclear about the test. I plugged in a pair of known-good earbuds using the headphone jack (not USB or Bluetooth, though I should check those at some point). When playing system sounds through the Settings app and video in YouTube, I did not hear any output from the earbuds and the sounds continued to play through the iMac speakers. Hope that's a better explanation of the test and results.

davidjo commented 3 years ago

Ive confirmed switching the dialog does not mute the speakers as I suspected (probably because Ive not fixed the automuting yet). This driver only deals with the internal audio system, USB/Bluetooth should just work. So if plugging in headphones does not mute the speakers its suggesting the unsolicited response system isnt working right. To try and fix this I would need the snd_hda log from your machine (ie grep for snd_hda in dmesg/syslog).

rogers06 commented 3 years ago

Here's the output from bootup thru plugging in and then unplugging a set of headphones. For clarity, there is a mic on this set of headphones. Hope it helps and glad to send more as needed.

rogers06@iMac-Ubuntu:~$ dmesg | grep snd_hda
[    5.537473] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040380
[    5.537754] snd_hda_intel 0000:01:00.1: enabling device (0000 -> 0002)
[    5.537789] snd_hda_intel 0000:01:00.1: Force to non-snoop mode
[    5.571607] snd_hda_codec_cirrus: loading out-of-tree module taints kernel.
[    5.571641] snd_hda_codec_cirrus: module verification failed: signature and/or required key missing - tainting kernel
[    5.572367] snd_hda_codec_cirrus hdaudioC0D0: autoconfig for CS8409: line_outs=2 (0x24/0x25/0x0/0x0/0x0) type:speaker
[    5.572368] snd_hda_codec_cirrus hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    5.572369] snd_hda_codec_cirrus hdaudioC0D0:    hp_outs=1 (0x2c/0x0/0x0/0x0/0x0)
[    5.572369] snd_hda_codec_cirrus hdaudioC0D0:    mono: mono_out=0x0
[    5.572370] snd_hda_codec_cirrus hdaudioC0D0:    inputs:
[    5.572370] snd_hda_codec_cirrus hdaudioC0D0:      Internal Mic=0x45
[    5.572371] snd_hda_codec_cirrus hdaudioC0D0:      Mic=0x3c
[    5.674965] Modules linked in: mei_hdcp snd_sof_pci snd_sof_intel_byt snd_sof_intel_ipc snd_sof_intel_hda_common snd_soc_hdac_hda snd_sof_xtensa_dsp snd_sof_intel_hda snd_sof snd_hda_ext_core snd_soc_acpi_intel_match intel_rapl_common snd_soc_acpi x86_pkg_temp_thermal snd_soc_core intel_powerclamp applesmc(+) coretemp snd_compress ac97_bus snd_pcm_dmaengine kvm_intel kvm snd_seq_midi snd_seq_midi_event snd_rawmidi snd_hda_codec_cirrus(OE+) crct10dif_pclmul snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi ghash_clmulni_intel brcmfmac snd_hda_intel snd_seq snd_intel_dspcfg aesni_intel snd_hda_codec hci_uart crypto_simd cryptd snd_hda_core glue_helper brcmutil snd_hwdep btqca rapl intel_cstate efi_pstore btrtl snd_pcm btbcm 8250_dw ee1004 snd_seq_device btintel cfg80211 apple_mfi_fastcharge(+) snd_timer bluetooth mei_me snd acpi_als kfifo_buf industrialio acpi_tad ecdh_generic ecc mei soundcore apple_bl intel_pch_thermal mac_hid sch_fq_codel parport_pc ppdev lp parport drm ip_tables
[    5.675059] Modules linked in: mei_hdcp snd_sof_pci snd_sof_intel_byt snd_sof_intel_ipc snd_sof_intel_hda_common snd_soc_hdac_hda snd_sof_xtensa_dsp snd_sof_intel_hda snd_sof snd_hda_ext_core snd_soc_acpi_intel_match intel_rapl_common snd_soc_acpi x86_pkg_temp_thermal snd_soc_core intel_powerclamp applesmc(+) coretemp snd_compress ac97_bus snd_pcm_dmaengine kvm_intel kvm snd_seq_midi snd_seq_midi_event snd_rawmidi snd_hda_codec_cirrus(OE+) crct10dif_pclmul snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi ghash_clmulni_intel brcmfmac snd_hda_intel snd_seq snd_intel_dspcfg aesni_intel snd_hda_codec hci_uart crypto_simd cryptd snd_hda_core glue_helper brcmutil snd_hwdep btqca rapl intel_cstate efi_pstore btrtl snd_pcm btbcm 8250_dw ee1004 snd_seq_device btintel cfg80211 apple_mfi_fastcharge(+) snd_timer bluetooth mei_me snd acpi_als kfifo_buf industrialio acpi_tad ecdh_generic ecc mei soundcore apple_bl intel_pch_thermal mac_hid sch_fq_codel parport_pc ppdev lp parport drm ip_tables
[    5.944428] snd_hda_codec_cirrus hdaudioC0D0: cs_8409_boot_setup_real headphone ALREADY PLUGGED IN UNIMPLEMENTED!!
[ 2420.828323] snd_hda_codec_cirrus hdaudioC0D0: cs_8409_interrupt_action - plug in
[ 2422.784783] snd_hda_codec_cirrus hdaudioC0D0: cs_8409_interrupt_action - headset detected
[ 2422.793471] snd_hda_codec_cirrus hdaudioC0D0: cs_8409_headset_type_detect_event headset does not have mike!!
davidjo commented 3 years ago

On the other hand - youve hit something else I cant try - I saw from Apples driver there are 3 headphone types detected, Apple with mike, non-Apple headphone only and non-Apple with mike - couldnt test non-Apple with mike because dont have such headphone!! Ill see if this needs fixing to at least allow headphones to work - although I thought it should just skip mike in this case.

ghost commented 3 years ago

Hi, Just thought I'd add some more info here. I am on Mac Pro 6.1 (late 2013 - AKA the trash can). My info is as follows: [root@fedora hwC0D0]# cat vendor_id 0x10134208 [root@fedora hwC0D0]# cat vendor_name Cirrus Logic [root@fedora hwC0D0]# cat subsystem_id 0x106b7800 [root@fedora hwC0D0]#

I have tried the patch but it does not work. I assume it's the wrong vendor_id. Would be glad to help in any way to get you the correct info you need from macOS running Big Sur on a Mac Pro 6.1. For the record, I got sound working by pairing airpods over bluetooth and using that instead.

Thanks a lot for great work!

davidjo commented 3 years ago

The vendor id says the chip is a 4208 - which I thought the original driver code should handle (my updates are for the 8409 chip). However I see under codec SSID matching in patch_cirrus.c for the cs4208_mac_fixup_tbl entity no 0x106b, 0x7800 is listed

ghost commented 3 years ago

Hi,

Yes, it is 6,1:

Base Board Information Manufacturer: Apple Inc. Product Name: Mac-F60DEB81FF30ACF6 Version: MacPro6,1 Serial Number: **** Asset Tag: Not Specified Features: Board is a hosting board Board requires at least one daughter board Board is replaceable Location In Chassis: MLB Chassis Handle: 0x0016 Type: Motherboard Contained Object Handles: 0

The patch works great on my macbook pro (2017) where the sound immediately started working after reboot. Thanks! Will try that.

ghost commented 3 years ago

Oh, wait. Are you asking if it's macbook air 6,1? This is a Mac Pro.

Also, by original do you mean this repo or another one? I recall there being a previous one but not sure if that's the one you are refering to. Thanks for all your help!

davidjo commented 3 years ago

No - just surprised we seem to have the same model 6,1 - so looks as tho we can have different subsystem ids for same model id 6,1 but MacBookPro vs MacBookAir. I meant going back to the original kernel patch_cirrus.c - except I think I also applied some patches to that which may have updated the 4208 coding - but its plausible anything I did apply has been added to the kernel version now.

maclinuxuser commented 3 years ago

Hi guys, sorry to sound like a noob but how do i apply the @egorenar patch_cirrus_new84.h patch. I have a 18,3 27" 5k Could someone please point me in the direction of some good instructions? Im not new to linux but am new to patching the kernel.

davidjo commented 3 years ago

Im assuming you have run install.cirrus.driver.sh which you should look thro - its not really a complicated script.

What Im doing here is building an updated kernel module snd-hda-codec-cirrus.ko outside of the kernel tree. In the directory where you ran install.cirrus.driver.sh you should see a directory patch_cirrus. This contains the updated files for building the updated module. patch_cirrus_new84.h patch is a patch file that should be applied to the patch_cirrus_new84.h in this directory using the patch command. Then re-run install.cirrus.driver.sh. This builds the module (under build/hda-your kernel version) and installs it into the actual kernel modules directory - usually /lib/modules.

maclinuxuser commented 3 years ago

Hi davidjo, thanks for the reply. Yes i installed using your install script, but still have no sound.

`vendor_id 0x10138409 vendor_name Cirrus Logic subsystem_id 0x106b1000

AppleHDATDMAmpMAX98706 0 AppleHDATDMAmpSSM3515 0 AppleHDATDMAmpTAS5758L 0 AppleHDATDMAmpTAS5764L 4 IOHDACodecFunctionSubsystemID 275451904

jason@debian:~/snd_hda_macbookpro$ sudo ./install.cirrus.driver.sh --2021-09-19 19:48:46-- https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.0.tar.xz Resolving cdn.kernel.org (cdn.kernel.org)... 151.101.29.176, 2a04:4e42:7::432 Connecting to cdn.kernel.org (cdn.kernel.org)|151.101.29.176|:443... connected. HTTP request sent, awaiting response... 404 Not Found 2021-09-19 19:48:47 ERROR 404: Not Found.

--2021-09-19 19:48:47-- https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.tar.xz Resolving cdn.kernel.org (cdn.kernel.org)... 151.101.29.176, 2a04:4e42:7::432 Connecting to cdn.kernel.org (cdn.kernel.org)|151.101.29.176|:443... connected. HTTP request sent, awaiting response... 416 Range Not Satisfiable

The file is already fully retrieved; nothing to do.

linux-5.10/sound/pci/hda/ linux-5.10/sound/pci/hda/Kconfig linux-5.10/sound/pci/hda/Makefile linux-5.10/sound/pci/hda/ca0132_regs.h linux-5.10/sound/pci/hda/hda_auto_parser.c linux-5.10/sound/pci/hda/hda_auto_parser.h linux-5.10/sound/pci/hda/hda_beep.c linux-5.10/sound/pci/hda/hda_beep.h linux-5.10/sound/pci/hda/hda_bind.c linux-5.10/sound/pci/hda/hda_codec.c linux-5.10/sound/pci/hda/hda_controller.c linux-5.10/sound/pci/hda/hda_controller.h linux-5.10/sound/pci/hda/hda_controller_trace.h linux-5.10/sound/pci/hda/hda_eld.c linux-5.10/sound/pci/hda/hda_generic.c linux-5.10/sound/pci/hda/hda_generic.h linux-5.10/sound/pci/hda/hda_hwdep.c linux-5.10/sound/pci/hda/hda_intel.c linux-5.10/sound/pci/hda/hda_intel.h linux-5.10/sound/pci/hda/hda_intel_trace.h linux-5.10/sound/pci/hda/hda_jack.c linux-5.10/sound/pci/hda/hda_jack.h linux-5.10/sound/pci/hda/hda_local.h linux-5.10/sound/pci/hda/hda_proc.c linux-5.10/sound/pci/hda/hda_sysfs.c linux-5.10/sound/pci/hda/hda_tegra.c linux-5.10/sound/pci/hda/hp_x360_helper.c linux-5.10/sound/pci/hda/patch_analog.c linux-5.10/sound/pci/hda/patch_ca0110.c linux-5.10/sound/pci/hda/patch_ca0132.c linux-5.10/sound/pci/hda/patch_cirrus.c linux-5.10/sound/pci/hda/patch_cmedia.c linux-5.10/sound/pci/hda/patch_conexant.c linux-5.10/sound/pci/hda/patch_hdmi.c linux-5.10/sound/pci/hda/patch_realtek.c linux-5.10/sound/pci/hda/patch_si3054.c linux-5.10/sound/pci/hda/patch_sigmatel.c linux-5.10/sound/pci/hda/patch_via.c linux-5.10/sound/pci/hda/thinkpad_helper.c make -C /lib/modules/5.10.0-8-amd64/build CFLAGS_MODULE="-DCONFIG_SND_HDA_RECONFIG=1 -Wno-unused-variable -Wno-unused-function" M=/home/jason/snd_hda_macbookpro/build/hda-5.10.0 modules make[1]: Entering directory '/usr/src/linux-headers-5.10.0-8-amd64' CC [M] /home/jason/snd_hda_macbookpro/build/hda-5.10.0/patch_cirrus.o /home/jason/snd_hda_macbookpro/build/hda-5.10.0/patch_cirrus.c: In function ‘cs_8409_init’: /home/jason/snd_hda_macbookpro/build/hda-5.10.0/patch_cirrus.c:1610:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 1610 | hinfo = spec->gen.stream_analog_playback; | ^ LD [M] /home/jason/snd_hda_macbookpro/build/hda-5.10.0/snd-hda-codec-cirrus.o MODPOST /home/jason/snd_hda_macbookpro/build/hda-5.10.0/Module.symvers CC [M] /home/jason/snd_hda_macbookpro/build/hda-5.10.0/snd-hda-codec-cirrus.mod.o LD [M] /home/jason/snd_hda_macbookpro/build/hda-5.10.0/snd-hda-codec-cirrus.ko make[1]: Leaving directory '/usr/src/linux-headers-5.10.0-8-amd64' cp snd-hda-codec-cirrus.ko /lib/modules/5.10.0-8-amd64/updates depmod -a

contents of /lib/modules/5.10.0-8-amd64/updates total 2588 -rw-r--r-- 1 root root 2649584 Sep 19 19:48 snd-hda-codec-cirrus.ko

jason@debian:~/snd_hda_macbookpro$ sudo dmesg | grep snd_hda_intel [ 5.343225] snd_hda_intel 0000:01:00.1: enabling device (0000 -> 0002) [ 5.343292] snd_hda_intel 0000:01:00.1: Force to non-snoop mode [ 5.494877] snd_hda_intel: UNKNOWN subsystem id 0x106b1000 [ 5.502057] snd_hda_intel: UNKNOWN subsystem id 0x106b1000`

jason@debian:/etc/modprobe.d$ sudo dmesg | grep snd_hda [ 5.343225] snd_hda_intel 0000:01:00.1: enabling device (0000 -> 0002) [ 5.343292] snd_hda_intel 0000:01:00.1: Force to non-snoop mode [ 5.452756] snd_hda_codec_cirrus: loading out-of-tree module taints kernel. [ 5.474418] snd_hda_codec_cirrus: module verification failed: signature and/or required key missing - tainting kernel [ 5.486525] snd_hda_codec_cirrus hdaudioC0D0: autoconfig for CS8409: line_outs=2 (0x24/0x25/0x0/0x0/0x0) type:speaker [ 5.486532] snd_hda_codec_cirrus hdaudioC0D0: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 5.486536] snd_hda_codec_cirrus hdaudioC0D0: hp_outs=1 (0x2c/0x0/0x0/0x0/0x0) [ 5.486539] snd_hda_codec_cirrus hdaudioC0D0: mono: mono_out=0x0 [ 5.486542] snd_hda_codec_cirrus hdaudioC0D0: inputs: [ 5.486546] snd_hda_codec_cirrus hdaudioC0D0: Internal Mic=0x45 [ 5.486549] snd_hda_codec_cirrus hdaudioC0D0: Mic=0x3c [ 5.494877] snd_hda_intel: UNKNOWN subsystem id 0x106b1000 [ 5.494916] snd_hda_codec_cirrus: probe of hdaudioC0D0 failed with error -1 [ 5.498311] snd_hda_codec_cirrus hdaudioC0D0: autoconfig for CS8409: line_outs=2 (0x24/0x25/0x0/0x0/0x0) type:speaker [ 5.498317] snd_hda_codec_cirrus hdaudioC0D0: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 5.498321] snd_hda_codec_cirrus hdaudioC0D0: hp_outs=1 (0x2c/0x0/0x0/0x0/0x0) [ 5.498324] snd_hda_codec_cirrus hdaudioC0D0: mono: mono_out=0x0 [ 5.498326] snd_hda_codec_cirrus hdaudioC0D0: inputs: [ 5.498330] snd_hda_codec_cirrus hdaudioC0D0: Internal Mic=0x45 [ 5.498333] snd_hda_codec_cirrus hdaudioC0D0: Mic=0x3c [ 5.502057] snd_hda_intel: UNKNOWN subsystem id 0x106b1000 [ 5.502088] snd_hda_codec_cirrus: probe of hdaudioC0D0 failed with error -1 [ 5.507103] snd_hda_codec_generic hdaudioC0D0: autoconfig for Generic: line_outs=2 (0x24/0x25/0x0/0x0/0x0) type:speaker [ 5.507109] snd_hda_codec_generic hdaudioC0D0: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 5.507113] snd_hda_codec_generic hdaudioC0D0: hp_outs=1 (0x2c/0x0/0x0/0x0/0x0) [ 5.507116] snd_hda_codec_generic hdaudioC0D0: mono: mono_out=0x0 [ 5.507119] snd_hda_codec_generic hdaudioC0D0: inputs: [ 5.507122] snd_hda_codec_generic hdaudioC0D0: Internal Mic=0x45 [ 5.507126] snd_hda_codec_generic hdaudioC0D0: Mic=0x3c

i dont ubderstand what you are saying here? patch_cirrus_new84.h patch is a patch file that should be applied to the patch_cirrus_new84.h in this directory using the patch command. Do i patch the patch file with the patch file? Sorry if im a bit slow but this stuff is new to me :)

alsa-info.sh http://alsa-project.org/db/?f=87df3c772bad69bb3eeb013fd13c6a0a07fb7cdb

davidjo commented 3 years ago

So I think the HTTP errors must have been random network issues.

The primary issue is snd_hda_intel: UNKNOWN subsystem id 0x106b1000 - if you get this you wont get sound as it means its a system the module doesnt know about.

You need to download https://github.com/davidjo/snd_hda_macbookpro/files/5792770/patch_imacs.diff.txt (first mentioned in comments above here) and yes use the patch command to apply these to the files in the patch_cirrus directory - this has the definitions for 0x106b1000.

maclinuxuser commented 3 years ago

Hey davidjo thanks for your help. once i worked out how to use the patch command i finally got it working. Thanks for all your hard work mate :1st_place_medal:

Also got it working in ArcoLinux kernel 5.14.6 but had to comment out these lines:

`else echo "linux kernel headers not found in /usr/src:" echo "Debian (eg Ubuntu): /usr/src/linux-headers-$(uname -r)" echo "Fedora: /usr/src/kernels/$(uname -r)" echo "assuming the linux kernel headers package is not installed" echo "please install the appropriate linux kernel headers package:" echo "sudo apt install linux-headers-$revpart3"

exit 1`

slynobody commented 2 years ago

18.2 / subsystem 0x106b0f00 / alsa.info as above (last of mani47): what patch to apply?

davidjo commented 2 years ago

This is still an unknown subsystem id so does not work currently. What would be useful is an ioreg listing from the imac running OSX. ioreg -l -a >'some file name'.xml

slynobody commented 2 years ago

Thanks for the quick answer. i did an ioreg (man, someshould take a look at all the 'telemetry'-entries!): true are: TAS5764L, CS42L83 and 8409 has an '77' entry?

davidjo commented 2 years ago

Thats interesting - so fortunately we do have code for TAS5764 amps however the code needs updating to add the new subsystem id to a number of if statements (essentially any if which tests for 0x106b1000 needs 0x106b0f00 adding as a condition).

(this is very confusing - Apple apparently has used 0x106b0f00 as a subsystem id for a totally different model previously so its nothing to do with the STAC922xx chip).

Im working on updating the code for kernel 5.15 (for Ubuntu 22.04 LTS release in April) with the new separate 8409 chip module for Dell laptops so will update imac ifs for 0x106b0f00 for that version

carrelebo commented 2 years ago

so will audio finally work for macbook and imac with this sound card with new version of ubuntu?

davidjo commented 2 years ago

Please try the new version - it should have updates for 0x106b0f00 iMac subsystem id.

phileagleson commented 2 years ago

The new driver is working as expected on my iMac 19,1 including the headphones (thanks again!). I am getting some pretty loud pops when audio starts in the headphones. Some research suggest this may be due to power save mode. The articles I found recommend setting /sys/modules/snd_hda_intel/parameters/power_save to 0. I attempted to do this in /sys/modules/snd_hda_codec_cs8409 but the parameters directory doesn't exist. Is there another way I can disable power save mode with this driver or could the popping be something else altogether?

davidjo commented 2 years ago

The codec should be permanently powered on (in the code power_save_node is set to 0) so I dont think its the power. (Although I do remember seeing the resume/suspend functions are still called before/after playing - but any power saving should be disabled).

I did some experiments on my macbook pro and I could get some nasty burst noises when using the touch bar volume controls or on first play after using volume controls. But then another time after the first volume control update which gave a noise then couldnt get any noises. Ill have to look into this further - maybe the cs42l83 chip and or 8409 headphone audio stream isnt being disabled properly.

When you say audio starts - was this the procedure boot, wait, plug in headphones, wait, then play something? Was if after playing something? Did you use the volume controls? It has been reported that eg skipping while playing videos in YouTube gives glitches.

carrelebo commented 2 years ago

a few hours ago i installed the patch on Ubtuntu 20.04 LTS with kernel 5.4, the sound was not working; I'll try with Ubuntu 22.04 later in the day. My model: Imac 18,1 (Intel)

phileagleson commented 2 years ago

My headphones are always plugged in as that is the only way I listen to audio so they were plugged in during boot. After logging in, I get 3 loud pops about 5-10 seconds after clicking login (sddm logging into xfce or leftwm). When I click a YouTube video I get 2 pops and then 2 each time I skip forward. I opened a second tab on twitch and shortly after got a high pitch squeal that made me have to take my headphones off. I killed the browser but the squeal continued for awhile, maybe 30-40 seconds. It did finally stop and it was still working as long as there is only 1 audio source. Volume works as expected when audio is normal. It did nothing while the squeal was happening

davidjo commented 2 years ago

I also got a squeal on headphones which continued when trying out things. Something is not getting updated right. By the way do you have GUI sounds enabled (I dont but stil got the noises). Your YouTube issue sounds like has been reported. Its interesting that you have them always plugged in at boot because I wasnt sure if that update was working - I had an attempted fix which Ive included in the new version. I think I was more focussed on getting plugging in/out headphones to work - didnt really check out having them in all the time that much. I need to do more testing!

davidjo commented 2 years ago

@carrelebo I dont know if 5.4 is working with new version so its disabled in the install script (unfortunately seem to have lost ability to boot 5.4 when moved my 20.04 system to external USB disk - it now drops into initramfs and doesnt appear to recgonise the USB disk - altho the same USB disk boots its last 5.8 hwe 20.04 kernel). So 5.8 is only kernel I have working for 20.04. The 22.04 version is much better because the mainline kernel has updates to handle the CS8409 which I had to hack around for pre-5.13 kernels.

carrelebo commented 2 years ago

@davidjo thank you for your answer, I finally have time after several unforeseen to try the patch for Ubuntu 22.04. I will let you know in a few minutes or hours, I will do several tests.

edit: And yes you are right about the CS8409 support, I had tried 22.04 quickly a while back and on Alsa mixer (terminal) I could at least see the name of the sound card.

carrelebo commented 2 years ago

I installed the driver on the two kernels "5.15.0.27" and "5.15.0.25", the installation of the driver went very well, even guided when packages were missing, only git is not installed by default. I installed both kernels on different Ubuntu installs to be sure, when starting Ubuntu the driver loads but either there is a kernel panic or it just does not start on the kernel where I installed the driver 20220514_130624

20220514_121118_mfnr

I will try under Arch Linux and Fedora Rawhide

davidjo commented 2 years ago

Not sure whats going on there but the many entries to cs8409_cs43l83_exec_verb means the module is loaded. Really need to see whats being logged before that stack trace - the multiple recursive calls dont look good. Need to try and get to the actual syslog file eg by booting using a linux recovery mode depending on how you are booting - is this a USB stick or on the main machine disk? If on main machine try making a usb stick linux then mount the main machine system disk.

carrelebo commented 2 years ago

I'm multi-booting with multiple systems, for Ubuntu I made a simple root partition with a boot partition. I haven't tried with the other distributions yet, so I still have my partitions, I can try chroot to get file or boot to kernel where I don't have driver installed.

carrelebo commented 2 years ago

I have access to the syslog and the kernel log, it displays that of "5.15.0.25", I need to install the driver on "5.15.0.27", I will give you the file with other details.

carrelebo commented 2 years ago

I installed it on the "5.15.0.27" kernel (it's the same result as the last times but when I had done with this kernel), you will find the /log directory of the /var directory so that you have everything the details. with the startup screen. directory : log.tar.gz 20220515_105944

Maybe it doesn't work because my Imac is 18.1 not 19.1

image

davidjo commented 2 years ago

Ah - thats likely a big problem - the lowest iMac version this module knows about is 18,2. Hmm looks like I need to skip some code if the subsystem id is not known - havent seen it crash out with unknown subsystem id before. On the other hand it is clearly is a CS8409 system otherwise it would not have loaded this module. Yes if you can boot to a kernel without the module and check the syslog for the version with the module installed thats the way to go.

carrelebo commented 2 years ago

I will do a fresh install of Ubuntu 22.04 and give you the logs for booting with kernel "5.15.0.27"

davidjo commented 2 years ago

You need to determine the subsystem id under linux try Subsystem ID from /proc/asound/card*/codec#0 (not sure which card eg card0, card1 will be the CS4208 - but thats the one you need). or an ioreg -l -x on OSX (actually would need an ioreg listing to determine the amps being used)

carrelebo commented 2 years ago

Here is what the command returns to me in OSX : file : ioregreturn.odt

davidjo commented 2 years ago

So your subsystem id is 0x106b0e00. From what Ive gleaned this appears to be similar to the current iMacs using the 8409 chip and TAS576 amps. What you need to do is to find all occurrences of (codec->core.subsystem_id == 0x106b1000 || codec->core.subsystem_id == 0x106b0f00) (ifs or else ifs mainly) in files in the patch_cirrus directory (patch_cirrus_apple.h, patch_cirrus_boot84.h, patch_cirrus_new84.h and patch_cirrus_real84.h) and replace it with (codec->core.subsystem_id == 0x106b1000 || codec->core.subsystem_id == 0x106b0f00 || codec->core.subsystem_id == 0x106b0e00 ). Then run the install script and try.

carrelebo commented 2 years ago

thank you, I will try in a few hours what you wrote, in case there will be no problem and the driver installs correctly and it works I will do a fork and maybe a tutorial.

carrelebo commented 2 years ago

I would like to thank you very much, it's been almost a year since I've been waiting for patches and some fixes including yours, only thank you, the sound works extremely well on Ubuntu, I'll try to make it work on Arch Linux or others to stay there . I made the fork for Imac 18.1: https://github.com/carrelebo/Imac-18-1_snd_hda_macbookpro

I saw that in the new occurrences the patch takes several subsystem identifiers at the same time, it would be nice for a new patch. Have you already offered your driver for the generic kernel? or have you ever heard of this git directory: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/log/?h=for-next&qt=grep&q=cs8409 ?

Otherwise a big thank you.

(I don't know how to develop a driver, if you have any recommendations to learn how to make it that would be great; and if I have to give a recommendation for the continuation of your project it will be to try to develop another driver for the built-in microphone)

If there is other problem, i will make an issue for Imac 18,1

davidjo commented 2 years ago

As I understand it this wouldnt get into the kernel - not that I would do it in its current state - because its too much based on logs from OSX. (On my macbook pro Im using the touchbar driver which is still not in the kernel source even tho it appears the author has been trying to get it in). (The new 8409 driver in the kernel from 5.13 was done I think by Cirrus employees - and I still cant find online documentation for the 8409 chip so we have no idea about all the vendor commands and which bits should be flipped).

Im also not a kernel developer - my primary goal was to get sound thro speakers as there are other solutions eg usb/bluetooth headphones/mikes which work out of the box. I actually want to use my laptop not spend time developing at this level!

The HDA driver seems to be a very complicated driver - it appears it was designed to make it very easy to add HDA chips based on the Intel standard. Unfortunately the 8409/42l83/speaker amp chip system doesnt fit well into this system so needs a lot of extra coding to work around the ease of use functions supplied by hda_generic.

The microphones are coded in (look for intmike in the source for internal mike) but are still at very early stage of development. Also the sound output is very low but so far appears to be the level the OSX driver returns. You need some alsa/pulse audio user config files to amplify the sound (I did actually record audio from my internal mike at one stage and used audacity to amplify to hearable level - try the alsa arecord command).

check the end of isse #23 for example of user config files - in this case to improve sound "quality" - altho for PopOS which apparently uses another user side sound system PIpewire rather than pulse audio.

carrelebo commented 2 years ago

@davidjo have you a social network where we can chat together ? (Like discord, twitter... Or other)

davidjo commented 2 years ago

Im on Discord - but was just using it because some piece of software I was interested in had setup a channel ie didnt use for anything else. So Im not familiar with doing things eg like setting up a channel.

phileagleson commented 2 years ago

I installed the latest version of the driver today but I'm still getting the pops and high pitch squealing on iMac 19,1. I'm not sure what info is helpful but here is the output of dmesg and lsmod | grep snd dmesglog.txt lsmodsnd.txt

If there is anything else I can provide or do to help please let me know. Thank you

davidjo commented 2 years ago

Can you try booting without headphones plugged in - its a scenario I dont really use and Im still not sure how good it is - then plug them in.

What is your OS? What is your audio system eg pulse audio?

What apps/programs were you using at the time of pops/squealing?