alsa-project/alsa-ucm-conf

master tree: Realtek ALC4080: "Failed to get the verb"

mavoga opened this issue · 21 comments

Hi,

wanted to test the UCM2 code in master for the onboard Realtek ALC4080 USB sound card (included in the list, 0db0:a073 MSI MAG X570S Torpedo Max); starting pulseaudio with new code causes this:

Oct 07 09:33:55 mybox systemd[2654]: Starting Sound Service...
-- Subject: A start job for unit UNIT has begun execution
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- A start job for unit UNIT has begun execution.
-- 
-- The job identifier is 540.
Oct 07 09:33:55 mybox pulseaudio[12140]: Failed to get the verb HiFi
Oct 07 09:33:55 mybox pulseaudio[12140]: Failed to get the verb HiFi 5+1
Oct 07 09:33:55 mybox pulseaudio[12140]: Failed to get the verb HiFi 7+1
Oct 07 09:33:55 mybox pulseaudio[12140]: No UCM verb is valid for hw:0
Oct 07 09:33:58 mybox pulseaudio[12140]: Failed to find a working profile.
[...]

v1.2.7.2 (without profile variants) works well. Is this expected in this development phase?

Debian up-to-date testing here, libasound2 v1.2.7.2

Thank you for your precious work!

Does commands alsaucm -c hw:0 dump text and alsaucm -c hw:0 set _verb HiFi work for you ?

Yes, they do. Here are the outputs:

$ alsaucm -c hw:0 dump text
Verb.HiFi {
        Comment "HiFi 2.0 channels"
        Device.Speaker {
                Comment Speakers
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        JackControl "Speaker - Output Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackChannels 2
                        PlaybackMixerElem PCM,0
                        PlaybackPCM "_ucm0001.hw:Audio"
                        PlaybackPriority 200
                        TQ HiFi
                }
        }
        Device.Headphones {
                Comment "Front Headphones"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        JackControl "Headphone - Output Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackMixerElem PCM,1
                        PlaybackPCM "_ucm0001.hw:Audio,1"
                        PlaybackPriority 300
                        TQ HiFi
                }
        }
        Device.SPDIF {
                Comment "S/PDIF Output"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackPCM "_ucm0001.hw:Audio,3"
                        PlaybackPriority 100
                        TQ HiFi
                }
        }
        Device.Line1 {
                Comment "Line Input"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        CaptureMixerElem Line,0
                        CapturePCM "_ucm0001.hw:Audio,1"
                        CapturePriority 100
                        JackControl "Line - Input Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        TQ HiFi
                }
        }
        Device.Mic1 {
                Comment Microphone
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        CaptureMixerElem Mic,0
                        CapturePCM "_ucm0001.hw:Audio,2"
                        CapturePriority 300
                        JackControl "Mic - Input Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        TQ HiFi
                }
        }
}
Verb."HiFi 5+1" {
        Comment "HiFi 5.1 channels"
        Device.Speaker {
                Comment Speakers
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        JackControl "Speaker - Output Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackChannels 6
                        PlaybackMixerElem PCM,0
                        PlaybackPCM "_ucm0001.hw:Audio"
                        PlaybackPriority 200
                        TQ HiFi
                }
        }
        Device.Headphones {
                Comment "Front Headphones"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        JackControl "Headphone - Output Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackMixerElem PCM,1
                        PlaybackPCM "_ucm0001.hw:Audio,1"
                        PlaybackPriority 300
                        TQ HiFi
                }
        }
        Device.SPDIF {
                Comment "S/PDIF Output"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackPCM "_ucm0001.hw:Audio,3"
                        PlaybackPriority 100
                        TQ HiFi
                }
        }
        Device.Line1 {
                Comment "Line Input"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        CaptureMixerElem Line,0
                        CapturePCM "_ucm0001.hw:Audio,1"
                        CapturePriority 100
                        JackControl "Line - Input Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        TQ HiFi
                }
        }
        Device.Mic1 {
                Comment Microphone
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        CaptureMixerElem Mic,0
                        CapturePCM "_ucm0001.hw:Audio,2"
                        CapturePriority 300
                        JackControl "Mic - Input Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        TQ HiFi
                }
        }
}
Verb."HiFi 7+1" {
        Comment "HiFi 7.1 channels"
        Device.Speaker {
                Comment Speakers
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        JackControl "Speaker - Output Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackChannels 8
                        PlaybackMixerElem PCM,0
                        PlaybackPCM "_ucm0001.hw:Audio"
                        PlaybackPriority 200
                        TQ HiFi
                }
        }
        Device.Headphones {
                Comment "Front Headphones"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        JackControl "Headphone - Output Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackMixerElem PCM,1
                        PlaybackPCM "_ucm0001.hw:Audio,1"
                        PlaybackPriority 300
                        TQ HiFi
                }
        }
        Device.SPDIF {
                Comment "S/PDIF Output"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        PlaybackPCM "_ucm0001.hw:Audio,3"
                        PlaybackPriority 100
                        TQ HiFi
                }
        }
        Device.Line1 {
                Comment "Line Input"
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        CaptureMixerElem Line,0
                        CapturePCM "_ucm0001.hw:Audio,1"
                        CapturePriority 100
                        JackControl "Line - Input Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        TQ HiFi
                }
        }
        Device.Mic1 {
                Comment Microphone
                Values {
                        CaptureCTL "_ucm0001.hw:Audio"
                        CaptureMixerElem Mic,0
                        CapturePCM "_ucm0001.hw:Audio,2"
                        CapturePriority 300
                        JackControl "Mic - Input Jack"
                        PlaybackCTL "_ucm0001.hw:Audio"
                        TQ HiFi
                }
        }
}
$ alsaucm -c hw:0 set _verb HiFi
ALSA lib main.c:826:(execute_sequence) unable to execute cset 'name='PCM Playback Switch',index=0 off'
ALSA lib main.c:2573:(set_verb_user) error: failed to initialize new use case: HiFi
alsaucm: error failed to set _verb=HiFi: No such file or directory

Thanks. Please, attach output from alsa-info.sh --no-upload. Thank you.

P.S.: my card has a specific mapping defined in https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/sound/usb/mixer_maps.c introduced with this patch.

It still doesn't work unfortunately; alsaucm -c hw:X set _verb HiFi now gives this:

$ alsaucm -c hw:2 set _verb HiFi
ALSA lib main.c:826:(execute_sequence) unable to execute cset 'name='PCM Playback Switch',index=0 off'
ALSA lib main.c:2573:(set_verb_user) error: failed to initialize new use case: HiFi
alsaucm: error failed to set _verb=HiFi: No such file or directory

It seems that the conditions in the new If.speaker_ctl {} and If.front_hp_ctl {} clauses don't match: by setting accordingly the variables on the top of the file, initialization occurs and the profiles start working.

Sorry for spamming but it looks there is something more that is broken in the new ucm configuration.

While testing the new use cases after manually setting the variables, I noticed that the volume control doesn't act on the ALSA mixer levels: the acoustic level changes, but by checking the effect of pulseaudio "volume up" and "volume down" while keeping alsamixer -c 2 open, I noticed that the ALSA mixer levels don't change. This happens both for speakers and headphone.
With old ucm configuration (v1.2.7.2) changing the volume also changed the mixer levels, Speaker* for speakers and Front Headphone when headphones were plugged in.

The detection should be fixed in perexg@c249755 / https://raw.githubusercontent.com/perexg/alsa-ucm-conf/c249755de9fc67476dbc66c5af79093380758033/ucm2/USB-Audio/Realtek/ALC4080-HiFi.conf .

For volume: show alsaucm -c hw:0 dump text for the new config.

Thanks, I confirm detection is fixed.

Here is the output of alsaucm alsaucm_dump_text.log.gz

The config looks correct:

PlaybackMixerElem Speaker,0
PlaybackMixerElem "Front Headphone,0"

Could you try this test change ?

diff --git a/ucm2/USB-Audio/Realtek/ALC4080-HiFi.conf b/ucm2/USB-Audio/Realtek/ALC4080-HiFi.conf
index b1e0130..bfa46e4 100644
--- a/ucm2/USB-Audio/Realtek/ALC4080-HiFi.conf
+++ b/ucm2/USB-Audio/Realtek/ALC4080-HiFi.conf
@@ -111,7 +111,7 @@ SectionDevice."Speaker" {
                PlaybackPriority 200
                PlaybackPCM "${var:SpeakerPCM}"
                JackControl "${var:SpeakerJack}"
-               PlaybackMixerElem "${var:SpeakerMixer},${var:SpeakerMindex}"
+               PlaybackMixerElem "${var:SpeakerMixer}"
        }
 
        Variant."HiFi 5+1".Value.PlaybackChannels 6
@@ -138,7 +138,7 @@ If.headphones {
                        PlaybackPriority 300
                        PlaybackPCM "${var:HeadphonesPCM}"
                        JackControl "${var:HeadphonesJack}"
-                       PlaybackMixerElem "${var:HeadphonesMixer},${var:HeadphonesMindex}"
+                       PlaybackMixerElem "${var:HeadphonesMixer}"
                }
        }
 }

Yes, apart from TQ after your last patch the 7+1 configuration is identical to v1.2.7.2, but mixer levels still don't change.
And as soon as I switch to v1.2.7.2 I can see the sliders moving when increasing/decreasing pulseaudio volume.
journalctl --user -xu pulseaudio.service doesn't show anything useful. Is there something I can do in order to debug this?

This is the output of alsaucm dump text after your last patch: alsaucm_dump_text+noindexes.log.gz

It seems that by commenting out the "PlaybackChannels 2" line the mixer levels start again to follow pulseaudio volume.

It looks like a problem in PA, could you create an issue in their bugtracker ? https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues

Ok, I will try with Pipewire too (which seems to be the future), I'll report here the results, then I'll decide what to do, thank you very much.

One last thing: I noticed that you removed the mixer control (switch) of the SPDIF port; if that control is not available the sound daemons won't be able to enable the port I suppose. I don't know the rationale behind your choice; if you think it'd be a good idea, I tested this patch against the last working version of your config and it seems to work well.

Thanks, the switch is added back in 0c8c5d8 . I have not had any alsa-info to gather this information from and got many other reports for hardware without mapping in the USB driver. It seems that this control is for cards without mapping:

Unit: 32
    Control: name="PCM Playback Switch", index=2
    Info: id=32, control=1, cmask=0x0, channels=1, type="INV_BOOLEAN"
    Volume: min=0, max=1, dBmin=0, dBmax=0``

PA and PW shares the identical UCM application code, so it's very likely, that the problem is also in PW.

Thank you Jaroslav.

I confirm that Pipewire behaves similarly to Pulseaudio (and in addition I have a very annoying issue with Pipewire: see here, UCM defined profiles are unavailable); the most important difference is that the controls steadily start to work when I manually select the proflle "HiFi 7+1", but they only work with such profile.

Will try to open an issue against Pulseaudio, thank you!

Opened Pulseaudio issue #1399

Hi @perexg could you please take a look at Pipewire bug #2744 and tell whether the profiles unavailable in Pipewire can be an UCM issue? Thanks!

The problem should be resolved with my fix in PW, so closing for now.