davidjo / snd_hda_macbookpro

Kernel audio driver for Macs with 8409 HDA chip + MAX98706/SSM3515 amps
GNU General Public License v2.0
275 stars 60 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

aydar-y commented 4 years ago

The result of aplay -L is below:

default Playback/recording through the PulseAudio sound server surround21 2.1 Surround output to Front and Subwoofer speakers surround40 4.0 Surround output to Front and Rear speakers surround41 4.1 Surround output to Front, Rear and Subwoofer speakers surround50 5.0 Surround output to Front, Center and Rear speakers surround51 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers null Discard all samples (playback) or generate zero samples (capture) samplerate Rate Converter Plugin Using Samplerate Library speexrate Rate Converter Plugin Using Speex Resampler jack JACK Audio Connection Kit oss Open Sound System pulse PulseAudio Sound Server upmix Plugin for channel upmix (4,6,8) vdownmix Plugin for channel downmix (stereo) with a simple spacialization hdmi:CARD=HDMI,DEV=0 HDA ATI HDMI, HDMI 0 HDMI Audio Output hdmi:CARD=HDMI,DEV=1 HDA ATI HDMI, HDMI 1 HDMI Audio Output hdmi:CARD=HDMI,DEV=2 HDA ATI HDMI, HDMI 2 HDMI Audio Output hdmi:CARD=HDMI,DEV=3 HDA ATI HDMI, HDMI 3 HDMI Audio Output hdmi:CARD=HDMI,DEV=4 HDA ATI HDMI, HDMI 4 HDMI Audio Output hdmi:CARD=HDMI,DEV=5 HDA ATI HDMI, HDMI 5 HDMI Audio Output hdmi:CARD=HDMI,DEV=6 HDA ATI HDMI, HDMI 6 HDMI Audio Output dmix:CARD=HDMI,DEV=3 HDA ATI HDMI, HDMI 0 Direct sample mixing device dmix:CARD=HDMI,DEV=7 HDA ATI HDMI, HDMI 1 Direct sample mixing device dmix:CARD=HDMI,DEV=8 HDA ATI HDMI, HDMI 2 Direct sample mixing device dmix:CARD=HDMI,DEV=9 HDA ATI HDMI, HDMI 3 Direct sample mixing device dmix:CARD=HDMI,DEV=10 HDA ATI HDMI, HDMI 4 Direct sample mixing device dmix:CARD=HDMI,DEV=11 HDA ATI HDMI, HDMI 5 Direct sample mixing device dmix:CARD=HDMI,DEV=12 HDA ATI HDMI, HDMI 6 Direct sample mixing device dsnoop:CARD=HDMI,DEV=3 HDA ATI HDMI, HDMI 0 Direct sample snooping device dsnoop:CARD=HDMI,DEV=7 HDA ATI HDMI, HDMI 1 Direct sample snooping device dsnoop:CARD=HDMI,DEV=8 HDA ATI HDMI, HDMI 2 Direct sample snooping device dsnoop:CARD=HDMI,DEV=9 HDA ATI HDMI, HDMI 3 Direct sample snooping device dsnoop:CARD=HDMI,DEV=10 HDA ATI HDMI, HDMI 4 Direct sample snooping device dsnoop:CARD=HDMI,DEV=11 HDA ATI HDMI, HDMI 5 Direct sample snooping device dsnoop:CARD=HDMI,DEV=12 HDA ATI HDMI, HDMI 6 Direct sample snooping device hw:CARD=HDMI,DEV=3 HDA ATI HDMI, HDMI 0 Direct hardware device without any conversions hw:CARD=HDMI,DEV=7 HDA ATI HDMI, HDMI 1 Direct hardware device without any conversions hw:CARD=HDMI,DEV=8 HDA ATI HDMI, HDMI 2 Direct hardware device without any conversions hw:CARD=HDMI,DEV=9 HDA ATI HDMI, HDMI 3 Direct hardware device without any conversions hw:CARD=HDMI,DEV=10 HDA ATI HDMI, HDMI 4 Direct hardware device without any conversions hw:CARD=HDMI,DEV=11 HDA ATI HDMI, HDMI 5 Direct hardware device without any conversions hw:CARD=HDMI,DEV=12 HDA ATI HDMI, HDMI 6 Direct hardware device without any conversions plughw:CARD=HDMI,DEV=3 HDA ATI HDMI, HDMI 0 Hardware device with all software conversions plughw:CARD=HDMI,DEV=7 HDA ATI HDMI, HDMI 1 Hardware device with all software conversions plughw:CARD=HDMI,DEV=8 HDA ATI HDMI, HDMI 2 Hardware device with all software conversions plughw:CARD=HDMI,DEV=9 HDA ATI HDMI, HDMI 3 Hardware device with all software conversions plughw:CARD=HDMI,DEV=10 HDA ATI HDMI, HDMI 4 Hardware device with all software conversions plughw:CARD=HDMI,DEV=11 HDA ATI HDMI, HDMI 5 Hardware device with all software conversions plughw:CARD=HDMI,DEV=12 HDA ATI HDMI, HDMI 6 Hardware device with all software conversions usbstream:CARD=HDMI HDA ATI HDMI USB Stream Output 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 dmix:CARD=PCH,DEV=0 HDA Intel PCH, Generic Analog Direct sample mixing device dsnoop:CARD=PCH,DEV=0 HDA Intel PCH, Generic Analog Direct sample snooping device hw:CARD=PCH,DEV=0 HDA Intel PCH, Generic Analog Direct hardware device without any conversions plughw:CARD=PCH,DEV=0 HDA Intel PCH, Generic Analog Hardware device with all software conversions usbstream:CARD=PCH HDA Intel PCH USB Stream Output

aydar-y commented 4 years ago

The result of systool -m snd_hda_intel -v is below:

Module = "snd_hda_intel"

Attributes: coresize = "53248" initsize = "0" initstate = "live" refcnt = "3" srcversion = "A1E50883834174BF30093EF" taint = "" uevent =

Parameters: align_buffer_size = "-1" bdl_pos_adj = "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1" beep_mode = "N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N" dmic_detect = "Y" enable_msi = "-1" enable = "Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y" id = "(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)" index = "1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1" jackpoll_ms = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" model = "imac27,(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)" patch = "(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)" pm_blacklist = "Y" position_fix = "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1" power_save = "1" power_save_controller= "Y" probe_mask = "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1" probe_only = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" single_cmd = "-1" snoop = "-1"

Sections:

aydar-y commented 4 years ago

Here's pacmd list-cards result:

2 card(s) available. index: 0 name: driver: owner module: 7 properties: alsa.card = "0" alsa.card_name = "HDA ATI HDMI" alsa.long_card_name = "HDA ATI HDMI at 0x81760000 irq 32" alsa.driver_name = "snd_hda_intel" device.bus_path = "pci-0000:01:00.1" sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card0" device.bus = "pci" device.vendor.id = "1002" device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]" device.product.id = "aaf0" device.product.name = "Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]" device.string = "0" device.description = "Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]" module-udev-detect.discovered = "1" device.icon_name = "audio-card-pci" profiles: output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 900, available: no) output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 800, available: no) output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 800, available: no) output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 700, available: no) output:hdmi-surround-extra1: Digital Surround 5.1 (HDMI 2) Output (priority 600, available: no) output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output (priority 600, available: no) output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 700, available: no) output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority 600, available: no) output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (priority 600, available: no) output:hdmi-stereo-extra3: Digital Stereo (HDMI 4) Output (priority 700, available: no) output:hdmi-surround-extra3: Digital Surround 5.1 (HDMI 4) Output (priority 600, available: no) output:hdmi-surround71-extra3: Digital Surround 7.1 (HDMI 4) Output (priority 600, available: no) output:hdmi-stereo-extra4: Digital Stereo (HDMI 5) Output (priority 700, available: no) output:hdmi-surround-extra4: Digital Surround 5.1 (HDMI 5) Output (priority 600, available: no) output:hdmi-surround71-extra4: Digital Surround 7.1 (HDMI 5) Output (priority 600, available: no) output:hdmi-stereo-extra5: Digital Stereo (HDMI 6) Output (priority 700, available: no) output:hdmi-surround-extra5: Digital Surround 5.1 (HDMI 6) Output (priority 600, available: no) output:hdmi-surround71-extra5: Digital Surround 7.1 (HDMI 6) Output (priority 600, available: no) output:hdmi-stereo-extra6: Digital Stereo (HDMI 7) Output (priority 700, available: no) output:hdmi-surround-extra6: Digital Surround 5.1 (HDMI 7) Output (priority 600, available: no) output:hdmi-surround71-extra6: Digital Surround 7.1 (HDMI 7) Output (priority 600, available: no) off: Off (priority 0, available: unknown) active profile: ports: hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no) properties: device.icon_name = "video-display" hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: no) properties: device.icon_name = "video-display" hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec, available: no) properties: device.icon_name = "video-display" hdmi-output-3: HDMI / DisplayPort 4 (priority 5600, latency offset 0 usec, available: no) properties: device.icon_name = "video-display" hdmi-output-4: HDMI / DisplayPort 5 (priority 5500, latency offset 0 usec, available: no) properties: device.icon_name = "video-display" hdmi-output-5: HDMI / DisplayPort 6 (priority 5400, latency offset 0 usec, available: no) properties: device.icon_name = "video-display" hdmi-output-6: HDMI / DisplayPort 7 (priority 5300, latency offset 0 usec, available: no) properties: device.icon_name = "video-display" index: 1 name: driver: owner module: 8 properties: alsa.card = "1" alsa.card_name = "HDA Intel PCH" alsa.long_card_name = "HDA Intel PCH at 0x81810000 irq 31" alsa.driver_name = "snd_hda_intel" device.bus_path = "pci-0000:00:1f.3" sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card1" device.bus = "pci" device.vendor.id = "8086" device.vendor.name = "Intel Corporation" device.product.id = "a348" device.product.name = "Cannon Lake PCH cAVS" device.form_factor = "internal" device.string = "1" device.description = "Built-in Audio" module-udev-detect.discovered = "1" device.icon_name = "audio-card-pci" profiles: input:analog-stereo: Analog Stereo Input (priority 15, available: unknown) output:analog-stereo: Analog Stereo Output (priority 1500, available: unknown) output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 1515, available: unknown) output:analog-surround-21: Analog Surround 2.1 Output (priority 1300, available: unknown) output:analog-surround-21+input:analog-stereo: Analog Surround 2.1 Output + Analog Stereo Input (priority 1315, available: unknown) output:analog-surround-40: Analog Surround 4.0 Output (priority 4200, available: unknown) output:analog-surround-40+input:analog-stereo: Analog Surround 4.0 Output + Analog Stereo Input (priority 4215, available: unknown) off: Off (priority 0, available: unknown) active profile: sinks: alsa_output.pci-0000_00_1f.3.analog-surround-21/#0: Built-in Audio Analog Surround 2.1 sources: alsa_output.pci-0000_00_1f.3.analog-surround-21.monitor/#0: Monitor of Built-in Audio Analog Surround 2.1 ports: analog-input-internal-mic: Internal Microphone (priority 8900, latency offset 0 usec, available: yes) properties: device.icon_name = "audio-input-microphone" analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: yes) properties: device.icon_name = "audio-input-microphone" analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: yes) properties: device.icon_name = "audio-speakers" analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: yes) properties: device.icon_name = "audio-headphones"

aydar-y commented 4 years ago

And here's pacmd list-sinks result:

1 sink(s) available.

aydar-y commented 4 years ago

The line in alsa-base.conf is set to:

options snd-hda-intel model=imac27

I tried most of the solutions out there and I would really appreciate your help on this.

davidjo commented 4 years ago

Unfortunately it doesnt appear the above logs have the information needed to determine the chip to see if this module is going to be useful. Look under /sys/class/sound you should see something like hwC0D0 (I believe for card 0 device 0) (there maybe others eg hwC1D0) which should be a linked directory - go into that directory and cat the following entries vendor_id, vendor_name, subsystem_id. do this for all similar entries and post them here. yes looking at the above aplay log you should have at least 2 - from the internal sound chip plus the hdmi sound for your graphics card - dont really need the hdmi entries

julianmaze commented 4 years ago

Thank you for opening up this issue @aydar-y

I have the same problem on my 2017 iMac 21.5" that I upgraded to Ubuntu 20.04 (previously 19.10). Spent quite a while installing these patches and attempting to fix the sound issue, but to no avail. Went ahead and grabbed the info requested by @davidjo

Here is my output. hwC0D0: vendor_id: 0x10138409 vendor_name: Cirrus Logic

hwC2D0: vendor_id: 0x1002aa01 vendor_name: ATI

Let me know if I can help.

davidjo commented 4 years ago

So indeed for hwC0D0 you have the Cirrus 8409 HDA chip (so this module is what is needed) - but I dont see the subsystem_id - there are specific checks in the code for the subsystem_id so if its different things wont work - one feature the subsystem_id detects is which amplifier chips you have (the HDA sends digital audio to the amplifier chips which have the DACs to convert to analog and send to the speakers). (hwCW2D0 is your graphics card)

davidjo commented 4 years ago

Another command to perform is: ioreg -l -a >'some file name'.xml

This dumps your IORegistry as an xml file. You then need to look for strings like AppleHDATDMAmpxxxxxxx eg AppleHDATDMAmpMAX98706 - there is a number associated with these fields. The one that is non-zero defines which amplifiers you have (currently this module only works for MAX98706 and SSM3515 amps). Other amps defined are TAS5758L or TAS5764L - which are not implemented yet and need access to a machine with those chips to dump an OSX log file before can begin to work on them.

aydar-y commented 4 years ago

Thanks for responding! Here's my info:

Here is my output. hwC0D0: vendor_id: 0x1002aa01 vendor_name: ATI

hwC1D0: vendor_id: 0x10138409 vendor_name: Cirrus Logic

I will provide the ioreg -l -a >'some file name'.xml output a bit later

aydar-y commented 4 years ago

Here's the output from IORegistry:

AppleHDATDMAmpMAX98706 0 AppleHDATDMAmpSSM3515 0 AppleHDATDMAmpTAS5758L 0 AppleHDATDMAmpTAS5764L 4

aydar-y commented 4 years ago

Or if the relevant numbers come in front: 3 AppleHDATDMAmpMAX98706 0 AppleHDATDMAmpSSM3515 0 AppleHDATDMAmpTAS5758L 0 AppleHDATDMAmpTAS5764L

davidjo commented 4 years ago

No Im afraid its the one after - so you have 4 of the TAS5764L amps which I dont have logs for. I dont have access to an imac to get OSX logs. In order to get logs we would need an Imac with High Sierra installed (because thats the OS I have a logging kext driver for - could be booted from external drive) and someone would need to replace the current AppleHDA.kext with the logging version and then play audio thro the internal speakers and dump the log. Also will really need the subsystem_id for the audio card - the same one with the vendor_id of 0x10138409 for your system - it should be in same place as vendor_id.

CuriousTommy commented 4 years ago

Hi @davidjo,

I don't think the iMac 19.1 is able to run High Serria. I believe it came with Mojave pre-installed.

davidjo commented 4 years ago

ah - didnt realise it was that later a model so unfortunately I dont have any Mojave install or plans to move to Mojave (Im still wary of APFS and when I started there was no way to read it under linux) - although theres a good chance I may be forced to if programs I use begin to require Mojave

doctordbx commented 4 years ago

Hi there, I have iMac 18,3 with the same configuration:

From ioreg

    <key>AppleHDATDMAmpMAX98706</key>
    <integer>0</integer>
    <key>AppleHDATDMAmpSSM3515</key>
    <integer>0</integer>
    <key>AppleHDATDMAmpTAS5758L</key>
    <integer>0</integer>
    <key>AppleHDATDMAmpTAS5764L</key>
    <integer>4</integer>

I'm happy to do what you need to get support for this device since I'm also keen to get Mint Linux working with my 18,3 iMac.

Let me know and I'll do what I can.

davidjo commented 4 years ago

Can you run High Sierra - eg install on spare SSD drive

doctordbx commented 4 years ago

I surely can. I'll install it today.

On Mon, 29 Jun 2020, 03:11 davidjo, notifications@github.com wrote:

Can you run High Sierra - eg install on spare SSD drive

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/davidjo/snd_hda_macbookpro/issues/11#issuecomment-650795180, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACPVFZHLBNGTWZNHS5EBYDRY52TZANCNFSM4M3HXZZQ .

doctordbx commented 4 years ago

OK, I installed High Sierra on my iMac, which was oddly a lot hard than I thought it would be due to issues with different USB controllers and booting from SSDs. But... I got there.

Let me know what you need.

davidjo commented 4 years ago

So next depends on what you are comfortable with. We need to replace the AppleHDA.kext with a logging version. This involves a number of stages: First, we replace the AppleHDA exec (/System/Library/Extensions/AppleHDA.kext/Contents/MacOS/AppleHDA) with an unsigned version - I use the github unsign program to do this. This lets us modify the kext (although I always disable SIP and gatekeeper before doing this). Second, we replace the IOHDAFamily exec (/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/IOHDAFamily.kext/Contents/MacOS/IOHDAFamily) with my logging version. I can send you the assembler source and build makefile if you are able to compile programs or I can send you the exec. Ill send my README files which reminds me how to activate the updated kernel extension. We boot the updated kernel (this takes a while because of the logging), play some sound and grep out the HDA log lines which you then send to me so I can figure out the amp programming.

doctordbx commented 4 years ago

Might be best just to send me the execs, it's a pretty bare bones install and just for this exercise. you can email me directly on my username and gmail dot com. Everything else will be easy enough. It's 10.40 pm here now and I'm heading to bed, but if you can drop them to me overnight I'll get what you need.

davidjo commented 4 years ago

OK will do - I was going to suggest emailing would be easier for this.

paniclabde commented 4 years ago

Hi, I'm on an iMac 18,3 too looking to fix my sound problems for elementaryOS / Ubuntu Bionic. Is there any progress on this issue or can I be of any assistance?

davidjo commented 4 years ago

I have some preliminary fixups which have been working on with doctordbx which seem to get the amps working but not the mikes - at the moment trying to figure out some other general issues - I can attach the the current version here but not ready to push them to the repo yet.

aydar-y commented 4 years ago

Hi David, do you have any progress with Catalina, or downgrading to High Sierra is the only way? Mohave?

davidjo commented 4 years ago

You have the AppleHDATDMAmpTAS5764L config so the fixups I have should at least get the amps working. Ive completed fixing the other issues so Ill check the TAS5764 coding and attach the updates here.

davidjo commented 3 years ago

I forgot - I need the subsystem id of the 19,1 imac - from the ioreg -l -a look for IOHDACodecFunctionSubsystemID it should report a big integer number after it then can update the subsystem_id ifs.

ndoroshenko commented 3 years ago

I forgot - I need the subsystem id of the 19,1 imac - from the ioreg -l -a look for IOHDACodecFunctionSubsystemID it should report a big integer number after it then can update the subsystem_id ifs.

Hi, @davidjo! I'm on iMac 18,3 (Retina 5K, 27-inch, 2017).

Seems that I have TAS5764L amplifier:

<key>AppleHDATDMAmpMAX98706</key>
<integer>0</integer>
<key>AppleHDATDMAmpSSM3515</key>
<integer>0</integer>
<key>AppleHDATDMAmpTAS5758L</key>
<integer>0</integer>
<key>AppleHDATDMAmpTAS5764L</key>
<integer>4</integer>

Perhaps,

<key>IOHDACodecFunctionSubsystemID</key>
<integer>275451904</integer>

might be the relevant value.

Let me know if I can help you with anything.

CuriousTommy commented 3 years ago

@davidjo I own an iMac19,1. I can confirm that the number is the same as @ndoroshenko

<key>IOHDACodecFunctionSubsystemID</key>
<integer>275451904</integer>
davidjo commented 3 years ago

Thanks - that indeed defines the subsystem ID as 0x106b1000 (275451904 in hex)

czosel commented 3 years ago

Hi @davidjo You mentioned above that you have some preliminary fixes to get the amps working - could you share them? I'm using an iMac 18,3 as well, and can confirm all the info posted by @ndoroshenko.

I'd be also happy to help out if you need anything - your work on this is greatly appreciated.

davidjo commented 3 years ago

Here is a patch which should add codes for the tas5764 amps - this should work for both 18,3 and 19,1 as according to the above the subsystem ids are the same. I think this plays audio but there are unresolved issues with recording.

Updated patch now included - with egorenar fixups

patch_imacs.diff.txt

egorenar commented 3 years ago

Here is a patch which should add codes for the tas5764 amps - this should work for both 18,3 and 19,1 as according to the above the subsystem ids are the same. I think this plays audio but there are unresolved issues with recording.

patch_imacs.diff.txt

Unfortunately, the patch doesn't apply cleanly to master.

This works for me on iMac27 5k: https://github.com/egorenar/snd_hda_macbookpro/commit/7e1e42cccd650b7f49b9920f71d64b582a8e1d19 Volume also :+1:

Thanks for your hard work Regards

CuriousTommy commented 3 years ago

Had to modify the install script, but I was able to compile @egorenar branch on Fedora 33. I can confirm that audio is working on my iMac19,1!

aydar-y commented 3 years ago

Didn't work for me on TAS5764. Is it still limited to High Sierra?

aydar-y commented 3 years ago

BTW, got this warning when installing the latest patch by @egorenar: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 1610 | hinfo = spec->gen.stream_analog_playback;

I'm using 5.7.1 kernel

davidjo commented 3 years ago

For OSX logs yes I havent tried to update to a later OS - but the linux driver can work on later machines if there havent been major changes to the audio hardware.

The compile error is expected - it stems from some debugging code I added early on - but it was only for logging.

Do you get any sound at all? What do you see on the Sound settings dialog for available outputs? Have you tried running the speaker test?

Have you tried: aplay -D hw:0,0 StereoTest32_reduced_m24dB.wav ? (Very important to use the reduced version).

mmalek-sa commented 3 years ago

Hi, I'm trying to apply the same patch from @egorenar branch to my iMac mid 2017 model and I'm getting this error, am I doing sth wrong?

make[1]: Entering directory '/usr/src/linux-headers-5.10.5-051005-generic'
  CC [M]  /home/agent47/projects/snd_hda_macbookpro/build/hda-5.10.5/patch_cirrus.o
/home/agent47/projects/snd_hda_macbookpro/build/hda-5.10.5/patch_cirrus.c: In function ‘cs_8409_init’:
/home/agent47/projects/snd_hda_macbookpro/build/hda-5.10.5/patch_cirrus.c:1617:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 1617 |         hinfo = spec->gen.stream_analog_playback;
      |               ^
  LD [M]  /home/agent47/projects/snd_hda_macbookpro/build/hda-5.10.5/snd-hda-codec-cirrus.o
  MODPOST /home/agent47/projects/snd_hda_macbookpro/build/hda-5.10.5/Module.symvers
  CC [M]  /home/agent47/projects/snd_hda_macbookpro/build/hda-5.10.5/snd-hda-codec-cirrus.mod.o
make[3]: *** No rule to make target 'scripts/module.lds', needed by '/home/agent47/projects/snd_hda_macbookpro/build/hda-5.10.5/snd-hda-codec-cirrus.ko'.  Stop.
make[2]: *** [scripts/Makefile.modpost:117: __modpost] Error 2
make[1]: *** [Makefile:1709: modules] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.10.5-051005-generic'
make: *** [Makefile:17: all] Error 2
cp snd-hda-codec-cirrus.ko /lib/modules/5.10.5-051005-generic/updates
cp: cannot stat 'snd-hda-codec-cirrus.ko': No such file or directory
make: *** [Makefile:22: install] Error 1

contents of /lib/modules/5.10.5-051005-generic/updates
total 0
davidjo commented 3 years ago

So I think things are sort of OK - the build is compiling but failing at the link stage. Im guessing because its listing 5.10.5 you are using kernel 5.10 so what I think has happened is that there has been a change to the build system for out of kernel module building for kernel 5.10 (the No rule to make target is the key indicator of this - scripts/module.lds is a component of the main kernel build system). This has happened before but I dont have a 5.10 system.

davidjo commented 3 years ago

It seems this is an Ubuntu bug - 1906131 in launchpad. A suggested quick fix in that bug is:

If anyone come across this looking for a workaround, here's a quick fix I've found on a GitHub repo for RTL8192EU

https://github.com/Mange/rtl8192eu-linux-driver/issues/205#issuecomment-736366347

sudo wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/module.lds.S -O /usr/src/linux-headers-5.10.2-051002-generic/scripts/module.lds

sudo sed -i '$ d' /usr/src/linux-headers-5.10.2-051002-generic/scripts/module.lds

davidjo commented 3 years ago

Im trying to consolidate a number of the fixups. I have corrected my error of failing to add the imac subsystem id in patch_cirrus_new84.h which @egorenar fixed. This patch should now apply to current master. Ive slightly modified the code organization compared to @egorenar.

patch_imacs.diff.txt

If this works Ill commit it to the main repo.

czosel commented 3 years ago

Thanks for your work on this @davidjo!

The patch indeed applies to the current master, and the installation also worked on my iMac 18,3 (Ubuntu 20.04 (5.4.0 Kernel) / Catalina) machine. However, no sound. The system dialog "Sound" shows three configurations for "Speakers - Built-in Audio":

I wasn't able to run the command you mentioned above, aplay -D hw:0,0 StereoTest32_reduced_m24dB.wav because I don't have the wav file.

mmalek-sa commented 3 years ago

Thanks so much for your work @davidjo, With your suggestion and using the patch you linked to, patch was successful but after reboot I still hear no sound. I tested with both speaker test and aplay (@czosel wav file is under test folder of Github repo):

snd

czosel commented 3 years ago

Thanks @mani47 - for me, there's no sound with the aplay command as well.

mmalek-sa commented 3 years ago

The output of sudo lspci -v for me:

00:1f.3 Audio device: Intel Corporation 100 Series/C230 Series Chipset Family HD Audio Controller (rev 31)
    Subsystem: Intel Corporation 100 Series/C230 Series Chipset Family HD Audio Controller
    Flags: bus master, fast devsel, latency 64, IRQ 57
    Memory at 92720000 (64-bit, non-prefetchable) [size=16K]
    Memory at 4000000000 (64-bit, non-prefetchable) [size=64K]
    Capabilities: [50] Power Management version 3
    Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Kernel driver in use: snd_hda_intel

01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Baffin HDMI/DP Audio [Radeon RX 550 640SP / RX 560/560X]
    Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Baffin HDMI/DP Audio [Radeon RX 550 640SP / RX 560/560X]
    Flags: bus master, fast devsel, latency 0, IRQ 58
    Memory at 92660000 (64-bit, non-prefetchable) [size=16K]
    Capabilities: [48] Vendor Specific Information: Len=08 <?>
    Capabilities: [50] Power Management version 3
    Capabilities: [58] Express Legacy Endpoint, MSI 00
    Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
    Kernel driver in use: snd_hda_intel
davidjo commented 3 years ago

Have you tried the @egorenar version? Could you try it and see if that works - Im debugging blind here because I have no imac.

Also can you look at your syslog (or kern.log) and see if you get any snd_hda_intel: UNKNOWN subsystem id 0x.... lines.

(You may need to fix the install script as done by @CuriousTommy)

mmalek-sa commented 3 years ago

Yes I tried @egorenar version and same result:

sudo dmesg | grep snd_hda_intel
[    2.216539] snd_hda_intel 0000:01:00.1: enabling device (0000 -> 0002)
[    2.216600] snd_hda_intel 0000:01:00.1: Force to non-snoop mode
[    2.298737] snd_hda_intel: UNKNOWN subsystem id 0x106b0f00
[    2.301061] snd_hda_intel 0000:01:00.1: bound 0000:01:00.0 (ops amdgpu_dm_audio_component_bind_ops [amdgpu])
[    2.310216] snd_hda_intel: UNKNOWN subsystem id 0x106b0f00

I also tried adding this option to the end of /etc/modprobe.d/alsa-base.conf which solved the issue for some people according to this SO thread: https://askubuntu.com/a/1264125

options snd-hda-intel model=generic

after doing this and reboot dmesg output is different but still no sound:

[    2.282241] snd_hda_intel 0000:01:00.1: enabling device (0000 -> 0002)
[    2.282340] snd_hda_intel 0000:01:00.1: Force to non-snoop mode
[    2.456854] snd_hda_intel 0000:01:00.1: bound 0000:01:00.0 (ops amdgpu_dm_audio_component_bind_ops [amdgpu])
davidjo commented 3 years ago

This is concerning - UNKNOWN subsystem id 0x106b0f00 - this is not one of the known subsystem ids - I think this message can only have come from the updated module. This message should never occur if things are working.

However, there are a quite a few kernel prints / dev_info with this message.

So if you could go thro patch_cirrus_new84.h and patch_cirrus_real84.h and add some eg unique number to each UNKNOWN print eg printk("snd_hda_intel: UNKNOWN 1 subsystem id 0x%08x",codec->core.subsystem_id); changing the number for each print (or dev_info print). Then rebuild etc and check the log again for UNKNOWN.

Also, can you look at the ioreg -l -a for your machine and search for 275451648 (0x106b0f00 in decimal) and see what item its associated with.

davidjo commented 3 years ago

So having looked around 0x106b0f00 is associated with a Sigmatel STAC922xx - which is implemented by the patch_sigmatel.c driver which already has fixups for macs.

What I dont understand is why such a machine would be loading the cirrus driver at all.

davidjo commented 3 years ago

Ah! So it appears the imac 18,2 does indeed use the 8409 HDA driver and must use a Sigmatel chip as the subsystem (which is different from the direct patch_sigmatel.c driver.

(The alsa-info.sh script would provide all the information).

Unfortunately this driver cant handle this - this would need an OSX log of the HDA commands from such a machine.