Bug 211005 - Sound channels definition issue on Asus Zenith II Extreme
Summary: Sound channels definition issue on Asus Zenith II Extreme
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-02 18:25 UTC by Urs Schroffenegger
Modified: 2022-09-07 10:51 UTC (History)
2 users (show)

See Also:
Kernel Version: 5.15
Subsystem:
Regression: No
Bisected commit-id:


Attachments
alsa-info output (21.00 KB, text/plain)
2021-01-02 18:25 UTC, Urs Schroffenegger
Details
lsusb (190.72 KB, text/plain)
2021-01-02 18:26 UTC, Urs Schroffenegger
Details
proc asound stream content (10.46 KB, text/plain)
2021-01-04 14:51 UTC, Urs Schroffenegger
Details
Test fix patch for USB mapping (2.47 KB, patch)
2021-01-04 16:51 UTC, Takashi Iwai
Details | Diff
alsa info output after patch 1 (24.04 KB, text/plain)
2021-01-05 17:58 UTC, Urs Schroffenegger
Details
pactl list output after patch 1 (23.01 KB, text/plain)
2021-01-05 17:58 UTC, Urs Schroffenegger
Details

Description Urs Schroffenegger 2021-01-02 18:25:25 UTC
Created attachment 294471 [details]
alsa-info output

Hi,

I'm trying to get the sound to work better on my Asus Zenith II Extreme motherboard. It's a TRX4 chipset motherboard with AMD Threadripper 3960 processor. From Asus' website, it has two chips:
1. Supreme FX S1220 Codec
2. ESS SABRE9018Q2C High Definition DAC

(And I suspect it also has some stuff to switch impedance sensing between front and back panel)

I think chip 1 is something based on the Realtek ALC1220-VB USB Audio, going through an Realtek ALC4050H bridge to USB, according to an anandtech visual inspection [1] and some comments in the Asus forums. Not sure if one chip takes care of the front audio and the other of the rear. Can't find a lot of information from Asus on their setup.

Basic analog sound works, but I have some issues with routing it and pulseaudio recognising it.
I have several issues: 
1. At boot, the analog sound output in pulseaudio is always the wrong one and is muted in alsamixer, the controls I have in alsamixer don't appear in pulseaudio.
2. The motherboard has a front panel output and a back panel output: both are called "USB Audio" in alsamixer and pulseaudio. (I think their order change sometimes with kernel updates)
3. Back panel output channels are called "Headphones" in alsamixer (maybe this is why they are muted at boot?)
4. It seems I can't use S/PDIF output as 5.1, can't use S/PDIF at all from pulseaudio.
5. Wasnn't able to use microphone in pulseaudio.

After doing some researching, it looks like there are some missmatches between pulseaudio and alsamixer, and identification of channels are a bit messy.
I found this bugreport [2] for a similar motherboard that looks pretty close to the issues I have and gave me some informations on what to test. It probably needs some mapping code for the outputs.

I made some test recordings and playback with arecord and aplay, I also found a test file with 5 channels, to test the outputs. Here is what I identified:

aplay -Dhw:1,0 test.wav   -> loudspeaker (5.1 analog output)
aplay -Dhw:1,1 test.wav   -> doesn't error out, couldn't identify what this is
aplay -Dhw:1,3 test.wav   -> loudspeaker (2 channel S/PDIF)
aplay -Dhw:2,0 test.wav   -> frontpanel headset output


arecord -Dhw:1,0 -f cdr test.wav -> no sound (maybe rear "line in" ?)
arecord -Dhw:1,1 -f dat test.wav -> records from rear panel mic in
arecord -Dhw:1,2 -f dat test.wav -> records from front panel mic in

I attach some dumps from the various tools that look like they could be usefull. I'm not a kernel nor sound developper, so not sure what to do here. I was able to download Linus' kernel branch and compile the v5.10 tag of his branch and install it as a package on my debian unstable
distribution, so I can test patches. I'd be glad for any help or pointers. 


[1] https://www.anandtech.com/show/15152/asus-rog-zenith-ii-extreme-review/2
[2] https://bugzilla.kernel.org/show_bug.cgi?id=206873
Comment 1 Urs Schroffenegger 2021-01-02 18:26:25 UTC
Created attachment 294473 [details]
lsusb
Comment 2 Takashi Iwai 2021-01-03 08:46:57 UTC
Could you give the contents of /proc/asound/card/*/stream* files, too?

For Zenith extreme II, we have a minimalistic quirk instead of the full mixer map, so something can be inconsistent.
Comment 3 Urs Schroffenegger 2021-01-04 14:51:22 UTC
Created attachment 294485 [details]
proc asound stream content

% ls /proc/asound/card*/                                                                        
/proc/asound/card1/:
id  pcm0c  pcm0p  pcm1c  pcm1p  pcm2c  pcm3p  stream0  stream1  stream2  stream3  usbbus  usbid  usbmixer

/proc/asound/card2/:
id  pcm0p  stream0  usbbus  usbid  usbmixer        

(as a sidenote, I have a NVidia card providing an HDMI output that I disabled through kernel modules, so it shouldn't appear here. And a USB webcam that was plugged on boot and appeared as card0 before I unplugged it. Just in case something in the numbering looks confusing. I got rid of those because I was a bit confused by all the devices appearing)
Comment 4 Takashi Iwai 2021-01-04 16:50:36 UTC
Below is a test patch to provide the mapping of units and mixer names as well as the jack connection routes.  Also the UCM profile names are set explicitly, too.
Let's see whether this works a bit better.
Comment 5 Takashi Iwai 2021-01-04 16:51:04 UTC
Created attachment 294489 [details]
Test fix patch for USB mapping
Comment 6 Urs Schroffenegger 2021-01-05 17:58:02 UTC
Hi, I applied the patch to Linus' v5.10 branch and rebooted and put my machine in the same state as before. Here is what I observe:

1. On boot, sound is not muted in alsa anymore.
2. Rear audio and back audio appear with "Zenith II Main Audio" and "Zenith II Front Headphone" in alsamixer.
3. Not sure what the relationship is between volume in aslamixer and volume in pavucontrol. Changing volume of the output I use in pavucontrol changes volume of alsamixer 'default' output. Main audio has it's own set of control in alsamixer, front headphone has no controls.
4. 5.1 analog output still works. I now got digital output over optical on hw:1,1 and hw:1,3, but only as stereo, not 5.1.
5. cards still both appear as "USB Audio" in pulseaudio, with their different profiles.  
6. alsa recording on front and back input still works. Looks like jack insertion is also detected correctly, it mutes/unmutes input with plugged in jack. Still not able to record from pulseaudio.

I attach curent alsa_info output and pactl list output. Not sure what I can test and what other info might help.

Thanks,

Urs
Comment 7 Urs Schroffenegger 2021-01-05 17:58:28 UTC
Created attachment 294515 [details]
alsa info output after patch 1
Comment 8 Urs Schroffenegger 2021-01-05 17:58:49 UTC
Created attachment 294517 [details]
pactl list output after patch 1
Comment 9 Takashi Iwai 2021-01-08 08:36:27 UTC
OK, it doesn't sound so bad, so far.

For PA, we'll likely need to create UCM profiles to manage the I/Os better.
alsamixer usually shows only the PA's main volume via alsa-lib plugin.  You can see the raw mixers via -c $CARD option (or -D hw:$CARD), though.

The remaining task is, in addition to the creation of UCM Profiles, the corrections of the mapping I've put in the patch.  Are the all I/Os listed there in the right place for the right purpose?  Or some need to be corrected?
e.g. I'm not sure whether it's really "Front" headphone jack or not.
Comment 10 Urs Schroffenegger 2021-01-13 17:12:27 UTC
Hi,

not sure exactly what those I/O in the patch amount to on the user side, so I'm not sure what to test.

Here is the output of alsactl monitor when plugging and unplugging a jack in each output.


Front headphone jack
--------------------
plug:
node hw:2, #3 (0,0,0,Headphone - Output Jack,0) VALUE  
unplug:
node hw:2, #3 (0,0,0,Headphone - Output Jack,0) VALUE

Front mic jack
--------------
  
plug:
node hw:1, #15 (0,0,0,Front Mic Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE
node hw:1, #12 (2,0,0,Mic Capture Switch,0) VALUE
node hw:1, #13 (2,0,0,Mic Capture Volume,0) VALUE
node hw:1, #13 (2,0,0,Mic Capture Volume,0) VALUE
node hw:1, #16 (2,0,0,Front Mic Capture Switch,0) VALUE
node hw:1, #17 (2,0,0,Front Mic Capture Volume,0) VALUE
node hw:1, #17 (2,0,0,Front Mic Capture Volume,0) VALUE
node hw:1, #17 (2,0,0,Front Mic Capture Volume,0) VALUE
node hw:1, #17 (2,0,0,Front Mic Capture Volume,0) VALUE

unplug:
node hw:1, #15 (0,0,0,Front Mic Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE
node hw:1, #16 (2,0,0,Front Mic Capture Switch,0) VALUE
node hw:1, #17 (2,0,0,Front Mic Capture Volume,0) VALUE
node hw:1, #17 (2,0,0,Front Mic Capture Volume,0) VALUE
node hw:1, #12 (2,0,0,Mic Capture Switch,0) VALUE
node hw:1, #13 (2,0,0,Mic Capture Volume,0) VALUE
node hw:1, #13 (2,0,0,Mic Capture Volume,0) VALUE

Rear panel mic in
-----------------
plug:
node hw:1, #11 (0,0,0,Mic Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE
unplug:
node hw:1, #11 (0,0,0,Mic Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE

Rear panel line in
------------------
plug:
node hw:1, #7 (0,0,0,Line Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE
node hw:1, #12 (2,0,0,Mic Capture Switch,0) VALUE
node hw:1, #13 (2,0,0,Mic Capture Volume,0) VALUE
node hw:1, #13 (2,0,0,Mic Capture Volume,0) VALUE
node hw:1, #8 (2,0,0,Line Capture Switch,0) VALUE
node hw:1, #9 (2,0,0,Line Capture Volume,0) VALUE
unplug:
node hw:1, #7 (0,0,0,Line Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE
node hw:1, #8 (2,0,0,Line Capture Switch,0) VALUE
node hw:1, #9 (2,0,0,Line Capture Volume,0) VALUE
node hw:1, #12 (2,0,0,Mic Capture Switch,0) VALUE
node hw:1, #13 (2,0,0,Mic Capture Volume,0) VALUE

Rear panel line out
-------------------
plug:
node hw:1, #7 (0,0,0,Line Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE
unplug:
node hw:1, #7 (0,0,0,Line Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE

Rear panel rear output
----------------------
plug:
node hw:1, #7 (0,0,0,Line Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE
unplug:
node hw:1, #7 (0,0,0,Line Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE

Rear panel c/sub output
-----------------------
plug:
node hw:1, #7 (0,0,0,Line Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE
unplug:
node hw:1, #7 (0,0,0,Line Jack,0) VALUE
node hw:1, #22 (0,0,0,Speaker Jack,0) VALUE


Alsamixer controls
==================

In alsamixer, when playing a 6 channel sound with 
$ pasuspender -- aplay -Dhw:1,0 snd51_all.wav
I have those controls:
Card1 - Zenith II Main Audio:
Speaker Front: changes volume of front right and front left speaker
Speaker Rear: changes volume on subwoofer and front center speaker
Speaker Center: changes volume on left rear
Speaker Woofer: changes volume on right rear
Speaker Side: doesn't seem to change volume of anything (also tested by playing sound on card2, front headphone)

Capture:
using arecord to record from front or back mic connection and changing capture volume in alsamixer for Card1
Mic: changes capture volume on rear panel mic in
Front Mic: changes capture volume of front panel 
Line: I don't think I have a device with the right impedance to test the back panel line in. 

Card2 - Zenith II Front Headphone doesn't show any control in alsamixer.
I didn't find how to control volume on the front headphone output. 

Digital output is still only stereo, has no volume control (but that's maybe by design).

I hope this helps you diagnose what's connected where. Tell me if there are other things I can test.

Thanks,

Urs
Comment 11 Urs Schroffenegger 2021-11-03 21:55:34 UTC
Hi,

I'm trying to revive this bug report and make some progress on this issue again. I applied the same changes to the source code for 5.14 from my debian unstable. I get the same behaviour as in my previous description:

I can play sound with aplay, I can record sound with arecord.

aplay plays a 6 channel wave correctly to the analog output. With the digital output (spdif), I only get the center and left/right output. If I understand correctly, I need to use a ac3 compression to get 5.1 output on digital? I didn't find a way to directly send an ac3 encoded file as passthrough to the digital output.

I tried with 
 $ pasuspender -- speaker-test -b 2000000 -c 6 -D"plug:{SLAVE=\"a52:1,'hw:1,1'\"}"

When I do this, I don't here anything, but interestingly, the "decode" LED on my z906 lights up, and the "stereo" doesn't light up (which indicates it detects a stereo digital stream). So it looks like it receives a correctly encoded stream, but there is no content in it.

For the client side, my debian distribution supports pipewire and pulseaudio, both seem to show the same behaviour. For my last tests, I reverted to pulseaudio, to avoid getting confused between alsa, pipewire, and pulseaudio connecting to a faked pulseaudio interface. I'm not sure who gets it's device and channel infos from where, so it's getting quite confusing.

I can use it with pulseaudio in analog mode. I wasn't able to get any sound out from the digital setup in the basic configurations. 
Poking around in configuration files, I found "/usr/share/alsa/cards/USB-Audio.conf", with a comment that sounded intriguing:



# If a device does not use the first PCM device for digital data, the device
# number for the iec958 device can be changed here.
USB-Audio.pcm.iec958_device {
    # "NoiseBlaster 3000" 42
    "USB Sound Blaster HD" 1
    "SB Omni Surround 5.1" 1

    "Xonar U7" 1
    "Xonar U7 MKII" 1
    "ASUS XONAR U5" 1
    "XONAR U5" 1
    "XONAR SOUND CARD" 1
    "Xonar SoundCard" 2
    "Zenith II Main Audio" 1   # <- added this
    ...
}

By adding that line, I was able to select the "Digital Stereo (IEC958) Output" in pavucontrol, and this way, I got some stereo out through the speakers using SPDIF and pulseaudio. Not sure if this is the way to go here, but at least it's a clue. But the "Digital Surround 5.1 (IEC958/AC3) Output" still doesn't make a sound. I saw there was a handfull of bug reports related to AC3 and a52 on the alsa-plugins issue tracker, so it might be related. 

On the recording side, I was able to record sound with arecord through alsa on the analog lines as before, but I wasn't able to get any sound recorded with pulseaudio. It looks like the setup works, there is just no sound recorded, the recorded wav file is just full of zeros.

Any clue on what I can do to push those issues forward is welcome,

Thanks,

Urs
Comment 12 Urs Schroffenegger 2021-12-09 21:11:26 UTC
Still same behaviour with 5.15.

Urs
Comment 13 Urs Schroffenegger 2022-08-08 10:09:23 UTC
Hi, I'm living with the same patch on kernel versions v5.16, v5.17, now on v5.18.6, which works for the most part. I spent some time reading up on ALSA/PA/PW, because there are still some issues I'm trying to fix.

Here is a summary of what works or not.

I ran the test with other devices unplugged and blacklisted the HDA driver to not have my NVIDIA card appear. In this way, I have the Main Audio on hw:0 and Front Headphone on hw:1. My machine is on Debian unstable, using PipeWire and  WirePlumber to control devices.

It looks like playing sound through alsa mostly works, for analog and digital.

aplay -D plughw:0,0 Nums_5dot1_24_48000.wav                         -> plays 5.1 analog sound through rear output
aplay  -D"plug:{SLAVE=\"a52:1,'hw:0,1'\"}" Nums_5dot1_24_48000.wav  -> plays 5.1 digital sound through SPDIF
aplay  -D"plug:{SLAVE=\"a52:1,'hw:0,3'\"}" Nums_5dot1_24_48000.wav  -> plays 5.1 digital sound through SPDIF
aplay -D plughw:1,0 Nums_5dot1_24_48000.wav                         -> plays stereo sound through front panel headset jack

Sound capture works too:

arecord -Dplughw:0,0 -f dat test_mic.wav -> line in capture, 2 channels
arecord -Dplughw:0,1 -f dat test_mic.wav -> rear mic capture, 2 channels
arecord -Dplughw:0,2 -f dat test_mic.wav -> front mic capture, 2 channels

alsa monitor still gives the same output as stated previously. It seems to detect rear mic, front mic, line in jack insertion and switches volume and input activation correctly when moving the jack around.

alsamixer for card 0 has some mixed up controls (same as previous). Here is the name of the control and what is effectively changing:

Speaker Front: front left and front right
Speaker Rear: subwoofer + front center
Speaker Center: rear left
Speaker Woofer: rear right
Speaker Side: nothing?

Output with Pipewire works, when selecting outputs in pavucontrol:
surround5.1 correctly outputs to 5.1 analog output
Digital Stereo IEC958 output to 5.1 digital output

What doesn't work is the input:
It shows ports correctly for the input (Microphone, Front Microphone, Line In), but I can select any of these, and the sound input will always be the device hw:0,0 (Line In). The pipewire node created seems to always be hw:0,0.

It looks like the ACP mapping it's currently using does something wrong.

I don't understand if this is related to alsa giving the wrong information, if something needs to be changed in ACP or if I should create a UCM profile. I'm trying to build a UCM profile, but without to much success for now, still need to learn a lot of stuff.

Any hint on where this input selection error comes from would be welcome. I can provide more info if it helps.

Thanks, 

Urs
Comment 14 Jaroslav Kysela 2022-08-08 10:36:05 UTC
Create UCM profile, some devices are already supported:

https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/USB-Audio/USB-Audio.conf
https://github.com/alsa-project/alsa-ucm-conf/tree/master/ucm2/USB-Audio/Realtek

If you need a help, create a pull request in the above repository and I'll try to reply to your questions.
Comment 15 Takashi Iwai 2022-08-09 07:27:28 UTC
For moving forward, let's merge the pending kernel patch.
I'm going to submit, to be included for v6.0-rc1.
Comment 16 Takashi Iwai 2022-08-09 07:34:29 UTC
The submitted patch:
  https://lore.kernel.org/r/20220809073259.18849-1-tiwai@suse.de
Comment 17 Urs Schroffenegger 2022-08-09 10:25:07 UTC
Great!

For reference, the work on the UCM2 is being done in the corresponding pull request here:

https://github.com/alsa-project/alsa-ucm-conf/pull/197

Thanks,

Urs
Comment 18 Urs Schroffenegger 2022-09-07 10:51:28 UTC
Hi, 

some progress update: I managed to make a UCM2 profile that seems to make the device appear conveniently in pipewire/pulseaudio (there is some channel swapping in 5.1 configuration happening, but this looks more like a pipewire and configuration issue than an driver issue. I need to understand how to tell pipewire to use the hardware channels by default for this card).

The next issue I need some help here is:

when I record sound with arecord (without pulse/pipewire), the recorded signal amplitude is really low, it seems to be only recording on a small number of codes of the 16bits of amplitude. (tested with two microphones, and testing to record with those mics on my laptop, after some changes to mic volume and mic boost, the signal is nice and covers the full amplitude).

Here are the amixer output:

$ amixer -c1
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right - Rear Left - Rear Right - Front Center - Woofer - Side Left - Side Right
  Limits: Playback 0 - 175
  Mono:
  Front Left: Playback 157 [90%] [-6.75dB] [on]
  Front Right: Playback 155 [89%] [-7.50dB] [on]
  Rear Left: Playback 155 [89%] [-7.50dB] [on]
  Rear Right: Playback 155 [89%] [-7.50dB] [on]
  Front Center: Playback 155 [89%] [-7.50dB] [on]
  Woofer: Playback 155 [89%] [-7.50dB] [on]
  Side Left: Playback 155 [89%] [-7.50dB] [on]
  Side Right: Playback 155 [89%] [-7.50dB] [on]
Simple mixer control 'Front Mic',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 79
  Front Left: Capture 79 [100%] [12.00dB] [on]
  Front Right: Capture 79 [100%] [12.00dB] [on]
Simple mixer control 'Line',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 40
  Front Left: Capture 40 [100%] [12.00dB] [off]
  Front Right: Capture 40 [100%] [12.00dB] [off]
Simple mixer control 'Mic',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 79
  Front Left: Capture 79 [100%] [12.00dB] [on]
  Front Right: Capture 79 [100%] [12.00dB] [on]


Everything is at a 100%, so I'd expect it to saturate the recording. (Signal is flat if I set recording volume to 0%, so the setting seems to be effective)

Could there be some missing mixer setting, like mic boost? I'm not sure at what level the issue can be here.

Thanks

Note You need to log in before you can comment on or make changes to this bug.