Skip to content

Dumping processing coefficients

Mike Beaton edited this page May 13, 2024 · 9 revisions

Normal ConfigData in AppleALC sets pin configs. But some cards on some systems also require vendor specific processing caps values to be set as well. The Tools script dump_coeff.sh helps to identify these additional values.

The Problem

Either:

a) You have found a layout in AppleALC which makes sound look as if it is working (all sliders etc. present) but there is no sound. The same card has working sound in Linux.

Or:

b) You have sound in a clean boot of macOS and Linux, but after using Realtek sound drivers in Windows, sound no longer plays in macOS or Linux. Again, sliders are present and sound looks like it is working, but there is no sound.

The Solution

Often, this is because certain processing capabilities on a vendor-specific node are not set (issue a.) or else are set but then actively cleared again (on shutdown) by Realtek sound drivers for Windows (issue b.).

The trick is to be able to compare the processing caps values between working sound and non-working sound.

For issue a. you need to get a dump of the params in Linux (with sound) and a dump of the params in macOS (no sound).

For issue b. you need to get a dump of the params on cold boot into macOS (i.e with sound) and on warm boot into macOS after Windows (i.e. no sound). (It is still useful to have an initial dump in Linux as well, to get the correct ncoeff value, see below.)

Linux Parameter Dump

Note: Can be done from a full install if you already have one, or from a Linux live USB.

First execute this command, which adds processing caps dump to Linux codec dumps, and lasts for the duration of the current boot:

echo 1 | sudo tee /sys/module/snd_hda_codec/parameters/dump_coef

Then dump the Linux codec using:

cat /proc/asound/card0/codec#0

You may need to vary the card or codec number.

Search the dump for "processing caps" - usually there will only be one node which has these. For each node(s) which has processing caps, there will be an ncoeff value.

macOS Parameter Dump

Use the dump-coeff.sh script from this repo.

  • device-index: Often 0, but you may need to vary this to access the right codec.
  • node-id: The same node id value seen in the Linux codec dump.
  • count: This should be the ncoeff value seen in the Linux codec dump.

alc-verb (available in AppleALC releases) must be installed on your path, and must also be enabled in config.plist (either write a non-zero value to the alc-verb property in DeviceProperties for your card, or add alcverbs=1 to boot-args).

The script will dump the processing caps values in macOS, in a similar format to the Linux codec dump: should be suitable for diff, after extracting just the relevant lines from the Linux codec dump.

Windows Parameter Dump

Info from hla63: "RtHDDump (windows app) on Asus blog" can be used to dump these values on Windows.

Now What?

Now you can see which processing caps are different. You may find say 10 or 11 values which are different. At this point a bit of guesswork and common sense is required, in order to figure out which values are important - typically you will only need to change 1 or 2 values to get sound, so you will need to experiment to find which ones matter.

Say that node 0x20, processing cap 0x37 is 0x0101 with sound, and 0x0100 without sound. Then to set the required value, you need to do:

alc-verb 0x20 0x5 0x37 (sets the processing coefficient index to read/write next)

alc-verb 0x20 0x4 0x0101 (sets the processing coefficient's value)

After the above commands, the codec will now be ready to write (or read) the next cap (0x38), so to test that the write worked we would need:

alc-verb 0x20 0x5 0x37 (sets the processing coefficient index to read/write next)

alc-verb 0x20 0xC 0x0 (read the value processing coefficient's value)

How to Make the Changes Permanent?

Hopefully, after a bit of playing with the above, you well get sound. Now you want to make the changes permanent. This requires packing the verbs and adding them to the ConfigData for your layout in AppleALC.

Verbs starting with 0x7 or 0xF are 3 digit (12 bit) verbs, e.g. 0x705, 0xF05. Other verbs are 1 digit (4 bit) verbs. The native macOS and native Intel HDA convention is to write 4 bit verbs as a single digit, e.g., 0x4, 0xC; but the Linux convention is to write them as three digits, always with 0 as the 2nd and 3rd digits, e.g., 0x400, 0xC00.

12 bit verbs are packed as follows:

0x0nnvvvdd

4 bit verbs are packed as follows:

0x0nnvdddd

where nn is the node id; v or vvv is the verb; dddd or dd is the data. (The packed version is always exactly the same, regardless of the convention used for writing the expanded verbs.)

For example:

alc-verb 0x20 0x5 0x37
alc-verb 0x20 0x4 0x0101

packs to:

0x02050037
0x02040101

Processing caps settings always come in pairs like the above example. The first verb is SET_COEF_INDEX (aka 0x5, 0x500) and sets the processing coefficient on the node which will be read or written by the next command. The second verb is SET_PROC_COEF (aka 0x4, 0x400) which actually sets the value.

Once you have found minimal verbs which enable sound by hand using alc-verb, you can pack them and add them to the end of the verb data in AppleALC ConfigData for your sound card and layout.

To try this out you can directly edit /EFI/OC/Kexts/AppleALC.kext/Contents/Info.plist on your EFI drive. Make sure to identify and edit the entry for the CodecID and LayoutID which you are using. You should add any new values to the end of the existing ConfigData.

AppleALC PR?

If you do fix the sound after Realtek Windows driver (and you have identified the minimum number of processing coefs which need to change) then it might be a good idea to submit the change as a PR to AppleALC, because it will likely fix the same issue for other users. You should check with the original layout author that they are happy with the change.

Note about alc-verb syntax

alc-verb 0x20 0x4 0x0101 can also be run as alc-verb 0x20 0x400 0x0101 or alc-verb 0x20 SET_PROC_COEF 0x0101 (i.e. alc-verb accepts Apple/Intel syntax or Linux syntax verbs).

On Linux (using hda-verb instead of alc-verb) the second two versions work, but not the first version (i.e. hda-verb only accepts Linux syntax verbs).

alc-verb prior to AppleALC 1.6.9 had slightly borked syntax when using 4 digit data with 1 digit verbs, so either use AppleALC 1.6.9 upwards (recommended) or for earlier versions modify commands sent to alc-verb as noted here.

Credits

  • hla63 for Windows dump info
  • narcyzzo for research leading to dump_coeff.sh script
  • mikebeaton for writing dump_coeff.sh script and instructions